#C6053. Unique Character Frequencies
Unique Character Frequencies
Unique Character Frequencies
Given a string S
consisting of digits and lowercase alphabetical characters, process the string to determine the unique characters in the order of their first appearance. For each unique character, compute its total frequency in the original string. Note that although adjacent duplicate characters may appear, the ordering is determined by the first occurrence in the string.
Example:
- Input:
aabbccdde
- Output:
(a, 2)
(b, 2)
(c, 2)
(d, 2)
(e, 1)
Note: The output should list each unique character and its frequency on a separate line, with the character and count separated by a single space.
inputFormat
The input is read from standard input as a single line string S
consisting of digits and lowercase letters.
outputFormat
For each unique character (in order of first occurrence), print a line containing the character and its total frequency in S
, separated by a space.
aabbccdde
a 2
b 2
c 2
d 2
e 1
</p>