Educative

Solution does not work

Hi, the optimal solution with O(1) space does not work for input = [-10, -1, 1, 1, 1, 1]. Can you please let me know how do we handle this test particular input in the given solution? This is actually the first test case and it fails

Hi, @swapnil_Jadhav1!

The second approach only works for non-negative numbers. There is a note mentioning the constraint. You can find the note above the Time Complexity heading.