#C6582. Character Frequency
Character Frequency
Character Frequency
You are given a string \(S\) composed of lowercase alphabetical characters. Your task is to count the number of occurrences of each character and output the results in the order in which the characters first appear in \(S\).
For each distinct character \(c\) in \(S\), output a line containing \(c\) and its corresponding frequency \(f(c)\), separated by a space. If the input string is empty, no output should be produced.
Example:
Input: aabccdeff Output: a 2 b 1 c 2 d 1 e 1 f 2
inputFormat
The input consists of a single line containing the string \(S\), where \(S\) consists of only lowercase letters (a
–z
).
outputFormat
For each distinct character in \(S\) (in the order of their first occurrence), print a line containing the character followed by a space and then its frequency.
## sampleaabccdeff
a 2
b 1
c 2
d 1
e 1
f 2
</p>