where is problem in the solution.
Your code fails on this test case-
Input 1 5 2 2 2 3 4 Your Output 3 Expected Output -1
I see a lot of if-else in your code. I say, if you havent already, check out other people’s code to see how they did it. You can come across something clever this way. Then, re-attempt it after 1-2 days.
Thanx for help
I will do as you say.