I am Getting WA Plz help

I am finding the error for nearly two days but i am still not able to plz help
here is the link for my solution Solution: 50564314 | CodeChef

we dont have to sort that array …
try using stack without sorting the array :slight_smile:

can you tell which test case is failing it will be very beneficial thanks

Check this test case (this could be the smallest test case your code fails).

Input

1
18
20 10 4 8 15 17 20 17 4 10 1 3 2 5 20 9 11 17

Expected Output

2

Your Output

-1
1 Like

N can not be 1 in this question btw thanks

1 Like

Thank you so much bro you really good I was unable to find cause it was so long test case

We’ll try finding smaller test cases :slightly_smiling_face:

no no i will debug now thanks

Try this

1
19
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 Likes

oh the constraint thank you… :slight_smile: good luck

lol thanks

debugged it Solution: 50614349 | CodeChef

After everything you’ve done, you should read the editorial. It will help you in approaching a problem in a better way.

I have already done the way in the editorial but i was wondering why I am wrong, Is it necessary to solve the problem by the way given in the ediotrials?