The problem is a straight forward implementation problem with strings. Anyone going with INT or LONG LONG INT will get wrong answer.
To get the problem right you need two things to do. Suppose you are on the "i"th digit of the input string then:

  1. Count the continuous appearance of the current digit. Say it is "x" times.
  2. Save the current digit as well. say it is "y".
    Then add the answers with the ans_string.
    ans_string += "x" + "y".

The catch with the problem is that you will get a TLE if not optimized. Say, wrongly handled in vector or NOT BREAKing INSTANTLY when x>9.

Statistics

76% Solution Ratio
AnikaTahsinEarliest, Dec '16
steinumFastest, 0.0s
steinumLightest, 5.5 kB
steinumShortest, 479B
Toph uses cookies. By continuing you agree to our Cookie Policy.