Test case failing

What is the problem with my code

hi… ur logic is not correct… u have to compress only consecutive characters… but u are doing something else./
consider this input
aaabbccdsaa

ur o/p
a5b2c2d1s1

expected o/p
a3b2c2d1s1a2

hope it clears ur doubt

ooh yess yess i got it

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.