Strings-String Compression

I am getting wrong answer in one test case. Here is my code: