Basic compression
Input
aaabbc
Output
a3b2c1
Three 'a's become 'a3', two 'b's become 'b2', one 'c' becomes 'c1'.
Full lesson preview
Implement run-length encoding by collapsing consecutive repeated characters into character+count pairs.
Problem statement
Task
Examples
Input
aaabbc
Output
a3b2c1
Three 'a's become 'a3', two 'b's become 'b2', one 'c' becomes 'c1'.
Input format
Output format
Constraints
Samples
Input
WWWWaa!!
Output
W4a2!2
Four 'W's, two 'a's, two '!' characters.