String compression 2 test cases fail

2 test cases are failed
also explain any other efficient approach

@taran9873
You are assuming that the input string will be sorted and no character will occur in two substrings .
Eg - Try this testcase :
Input :
dddqqaabbbbaa

Expected Output :
d3q2a2b4a2

Your Output :
a4b4d3q2

No need to store the frequencies. Try running a loop over the string. As soon as you come to a character , run another nested loop from that character till the character is repeating.
for(int i=0;i<s.size();i++) {
for(int j=i+1 ; j<s.size() && s[j] == s[i] ; j++) {
--
}
}
As soon as you end up on a new character , move i to j+1 and print s[i] along with its occurrences which will be given by j-i .

can u provide me solution code
that will help me understand better

@taran9873
I cannot provide you with the solution code. I will be glad to help you out in making modifications to your own code though.

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.