How is this solution getting AC?

http://www.codechef.com/viewsolution/3784470

Can somebody tell me how is this getting accepted. I ran it on ideone and it is giving wrong answer for the sample test cases.

2 Likes

Some reason posting same question several times?

Actually first I didn’t understand this solution, that’s why I posted a question about it. Later when my friend found out just printing “-2” is getting AC, he made it a separate question.

I see now, I looked at it from question list and as you added comment there was same name in the list, sorry.