Help with "Chef and Frogs" (FROGV)

I tried doing what is said in the editorial. But getting WA. Can anyone help me find out where am I going wrong, or give any test case where my code fails. I’ve tried with different test cases, it passes all of them. It also passes the sample test cases. Please help…!

LINK TO MY CODE : Solution

You’ve got some off-by-one error. Your condition on line 46 leaves you susceptible to a case like this:

3 2 1
1 5 7
2 3

Also, what’s with the arbitrary arr[i] + 3 on line 35? That will probably mess you up too.

Thank you so much…! I figured out the error…