Letter Counter
InterviewTime limit1sMemory limit512 MB
Count how many times each letter appears across the given lines and print nonzero counts from a to z then A to Z.
Problem
A club of young code-breaking enthusiasts is building software to decrypt an ancient manuscript. The heart of the system will be a self-learning text analyzer, and its first module, a 'letter counter', has been entrusted to you.
Write a program that:
- reads the text to analyze from standard input,
- for each letter, counts how many times it appears in the text,
- prints the result to standard output.
Input
The first line contains an integer , the number of text lines to analyze (). Each of the next lines contains a string of at most characters made up of lowercase and uppercase Latin letters ('a'..'z', 'A'..'Z') and spaces.
Output
For the letters 'a' through 'z' and then 'A' through 'Z' (in that order), print one line for each letter that appears in the text: the letter, a single space, and the number of times it occurs. Skip any letter that does not appear in the text.