In order of n-square I’m able to pass all the testCases but if I try to run my code with some modification it’s not able to pass testCase #1, Can you tell me where I went wrong.
Link to my code is.
In order of n-square I’m able to pass all the testCases but if I try to run my code with some modification it’s not able to pass testCase #1, Can you tell me where I went wrong.
Link to my code is.
Consider test case:
1 6
18 21 27 38 55 67
55
Expected Output:
1
Your Output:
0
Dry run and check where your code goes wrong.
I would suggest you to follow the staircase search approach for this question which is O(n). Lecture video on this approach is already there in your playlist.