In this problem i am getting TLE for first constraint which is smaller than original constraint but my program passes all other test cases even the test cases with original constraint. Why is it so?
Here is a case for which your code gives TLE.
1 7 7 1 2 3 4 5 6 7
P.S. There are some conditions you should introduce in else statement to avoid it.
Thanks a lot sir. Now passing all the test cases.