Practice · 2 of 5
Run-Length Encode
CHALLENGE
Difficulty: beginner+25 XP
**Description:** Compress a string by replacing each maximal run of equal characters with
the character followed by the run length.
**Input:** One line: s (1 <= |s| <= 10^6, lowercase letters).
**Output:** The RLE string.
**Example:** aaabbc -> a3b2c1.
Press Submit to check your solution.
Back to lesson: Practice: String Problem Set