#K63367. Group Consecutive Characters with Counts
Group Consecutive Characters with Counts
Group Consecutive Characters with Counts
You are given a string s
consisting of characters. Your task is to group consecutive identical characters in the string and output each character followed by the count of its consecutive occurrences.
For example, for the input string aabbccaa
, the output should be a2b2c2a2
.
This problem requires you to read the input from stdin
and write the result to stdout
. If the input string is empty, output an empty string.
Note: If there is a formula or any mathematical notation in your explanation, you must use LaTeX format. However, this problem does not include such formulas.
inputFormat
The input consists of a single line containing the string s
. The string may be empty.
Input Format:
s
outputFormat
Output the transformed string which consists of each character from the input followed by the number of times it appears consecutively. If the input string is empty, output an empty string.
Output Format:
result## sample