Getting WA in Compilers and parsers

Hi, I tried many test cases but not able to find why my code is giving WA
Solution link: CodeChef: Practical coding for everyone
Any help is really appreciated.

Well, I think the error is related to res += i+1. You want the longest preffix, this way you are getting the sum of (maybe) several preffixes. And once your count becomes -1, you should update the res up to that point. I hope this helps some way :slight_smile:

Got it, thanks a lot