TLE in two test cases

How can i optimize this code

@hemantomer1
optimized approach

  1. Take the first character of the present string and store it in say β€˜ch’. Start iterating over the string and obtain the count of this character occurring consecutively from this point.
  2. Obtain the answer for remaining string recursively.
  3. Return ch+countOfCh+recursiveResult .
    editorial code for ref
    https://ide.codingblocks.com/s/279900
    dont forget to hit like and mark resolved if cleared :smiley:
1 Like

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.