#C5344. Run-Length Encoding Compression
Run-Length Encoding Compression
Run-Length Encoding Compression
Implement a run-length encoding compression algorithm. Given a string, compress consecutive repeating characters by representing them as the character followed by the count if the count is greater than 1.
For example, the string aabcccccaaa
should be compressed to a2bc5a3
while the string abcd
remains unchanged. Handle all edge cases, including an empty string and strings with a single character.
inputFormat
The input consists of a single line read from standard input (stdin) representing the string to compress.
outputFormat
Print the compressed string to standard output (stdout).## sample
aabcccccaaa
a2bc5a3