I have written my peice of code for string compression but it is failing for 2 testccases. please review it and tell me about any logical errors if present .
The link to my code https://codeshare.io/2WVV4y
Two testcases wrong
Consider a test case:
sskkkkkkwaerrtss
Expected Output:
s2k6w1a1e1r2t1s2
Your o/p:
s4k6e1r2t1s4
so how to correct this in my code ?
Just dry run your code and check it how your logic is going is going. You can observe the pattern from the above case i mentioned.
You can maintain the count of each character while iterating through the string and print its count at the moment when current character is not equal to previous character.
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.