Unable to pass all test case

Hi please check my code. It’s working for all test cases i’ve been passing. I believe itt’s correct. It is O(n).
Help me identify what’s wrong

hello @vaani787

you have misunderstood the problem.
here u only have to compress consecutive same characters.

for ex->
aaabbbaac
output should be
a3b3a2c1

Hey! I am still getting wrong answers please check!

@vaani787

try this case->
aaaaaa

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.