LONGSEQ: Solution not getting accepted

Can anybody please let me know what is the flaw in my program due to which I am getting wrong answer.

My solution: CodeChef: Practical coding for everyone

Your solution fails in case the length of the input is 1 (or in other words, if the number of digits in the number is one).

Just add another condition to handle it before calculating the indexes

if(str.length() == 1) {

Hope it helps.

yes, it worked.
Thank you very much…