Compressed String Getting WA (logic incorrect or corner-case missing ?)

I tried this question alot but still getting WA.can someone tell if my logic is incorrect or I am missing something here!
https://www.codechef.com/viewsolution/14415120