Ad
  • Default User Avatar

    Based on the conditions, all solutions that are tested - are wrong.

    For example input:
    a = [2147483647]
    b = [1]
    2147483647 * 2147483647 == 1 // of the overflow type in java
    and all decisions will be shown true, but 2147483647 is not a root of 1.

    Or this entry:
    a = [-2]
    b = [4]
    -2 * -2 == 4
    solutions show true, but -2 it is not the root of 4.

    I'm about two hours could not understand what went wrong in the eighth test, because of this.
    I looked at other solutions, they first, each element of the array "a" squared, and then arrays are sorted and compared, but it is wrong.
    a = [2147483647, 7, 4] -> [1, 49, 16] -> [1, 16, 49]
    b = [49, 1, 16] -> [1, 16, 49]
    and the result is true, though to be false.