Ad
  • Default User Avatar

    Of course! That makes sense and I should have saw that. The random tests would use the same input to validate. Static tests would know what output to expect.

    Thanks.

  • Default User Avatar

    Since you fail the random tests I strongly suppose that you modify the given input (for example you reverse it in place) and so the reference solution for the random tests doesn't work on the "good" array. Work on a copy of the given input. Cheers.

  • Custom User Avatar

    Given almost all posts about getting timeout are marked as having spoilers because they have, and the same answers are repeated over and over, read this if that's your case:

    Your code's time complexity is O(n2) and that won't work here. You code's time complexity should be O(n) to pass. Try googling "Big O notation" (it's a long subject to explain it here properly), your code should work in linear time, so if your code use nested loops or a loop and a loop-alike method inside try another way.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution