String Compression - Help

Sir, below is my code. My sample test case is passing, what is wrong in the code?

https://ide.codingblocks.com/s/69869

@amartya970914 hey amartya I am corrected your code you can refer this.

Hey Amartya,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.