#C9232. Letter Frequency Counter
Letter Frequency Counter
Letter Frequency Counter
Given a string s
consisting solely of lowercase letters, compute the frequency of each letter in s
.
The output should contain one line per distinct letter found in s
, formatted as letter: frequency
. The letters must appear in alphabetical order. Mathematically, the frequency of a letter \( c \) can be defined as:
$$ f(c) = \text{number of occurrences of } c \text{ in } s $$
For example, for s = "banana"
, the output should be:
a: 3 b: 1 n: 2
inputFormat
The input consists of a single line containing a non-empty string s
(1 ≤ |s| ≤ 105) that includes only lowercase English letters.
outputFormat
For each distinct letter in s
(sorted in alphabetical order), output a line in the format letter: frequency
without extra spaces.
banana
a: 3
b: 1
n: 2
</p>