String compression

Sir, I’m reaching there than how to reach to the solution

hey @sb8031151_af528e7b895c738c This might help :
The Logic is Simple which says that all you need to count the number of consequtive same characters are present and add each character with its frequency into StringBuilder.

Algo

1.Traverse on the String.
2.If the Character is same as the next one simply increment count.
3.otherwise append the repeated character.
4.also append the count of it is greater than 1.
5.return by converting the corresponding StringBuilder to String.

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.