Compress repeated letters
Replace each run of the same character with the character followed by the length of the run.
Reported in: Capgemini (memory-based)
Input
One line: the string.
Output
The compressed string.
Constraints
1 ≤ length ≤ 10^5.
Example 1
Input:
aaabbcaa
Output:
a3b2c1a2Example 2
Input:
xyz
Output:
x1y1z1Hint: Walk the string, counting how long the current character repeats.