Run-Length Encoding
Compress the string by replacing every maximal run of equal characters with the character followed by the run length. aaabbc becomes a3b2c1.
Input: one line with the string S.
Output: the run-length encoding of S.
Constraints:
- 1 ≤ |S| ≤ 104
- S contains lowercase English letters
Sample Tests
Input 1
aaabbc
Output 1
a3b2c1
Input 2
abc
Output 2
a1b1c1
Discussion (opens after you solve — no spoilers before)
No comments yet.