Ad
  • Default User Avatar

    I can see you have nested for loops making your solution O(n^2) which wont work for some of the test cases. You need to find a way to solve it with a O(n).

  • Default User Avatar

    Your code is not optmised to work with longer arrays, whilst your code likely works, it takes too long to solve the harder problems so times out. This questions is as much an optimisation problem as any. So you need to find a way to optimise your solution