You need to sign in or sign up before continuing.×
Ad
  • Custom User Avatar
    1. You created a (shallow) copy of the input array but then proceeded to mutate the input array itself - that alone causes undefined behavior and makes your solution likely to fail the random tests (even if you pass the fixed tests)
    2. Arrays in JS (and almost every other programming language) are compared by reference, not by value. To check whether two arrays have the same content, you will have to loop through the array and compare each element from both arrays for equality.