Testcase no. 2 is wrong

question says whose frequency is once should not print .
Why my code not work fully?

Please do code (or make changes ) using char array not with string

this is because you approach is will not work in all cases

here you have to compression the string

For INPUT
aabbaacc
Your output
a4b2c2
but correct output is
a2b2a2c2

correct approach

1 Like

oh I misread question Thanks so much &You can mark as resolve

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.