#C10294. String Compression
String Compression
String Compression
Given a string s, compress it by counting consecutive repeating characters. For example, if a character c appears consecutively n times, it should be replaced by c followed by n (in latex: \( c\,n \)). For instance, the string aabcccccaaa
will be compressed as a2b1c5a3
. Implement this compression technique.
inputFormat
The input is provided via stdin as a single line containing the string s (only alphabetical characters) that needs to be compressed.
outputFormat
Output the compressed string to stdout. The output format is exactly the compressed string with each character followed by the count of its consecutive occurrences.
## sampleaabcccccaaa
a2b1c5a3