← 返回 oracle 的题目列表Run-Length String Compression
类型:online_judge
Implement run-length string compression. Scan a string s from left to right and group consecutive identical characters:
If a character occurs once in its consecutive group, output the character itself.
If it occurs more than once, output the character followed by its count.
For example, aaaaabbbccca becomes a5b3c3a.
Input
One non-empty string s containing printable ASCII characters other than newline.
Output
The compressed string.
Constraints
1 <= |s| <= 2 * 10^5
Example
Input
aaaaabbbccca
Output
a5b3c3a