#C13537. Case-Insensitive Word Count
Case-Insensitive Word Count
Case-Insensitive Word Count
You are given a list of words. Your task is to count the occurrence of each unique word in a case-insensitive manner.
More formally, given a number \(n\) and a list of \(n\) words, convert all words to lowercase and compute the frequency of each word. Finally, output the words along with their respective counts, sorted in lexicographical (alphabetical) order.
Note: The input is provided via stdin
and the output should be written to stdout
.
inputFormat
The first line contains an integer \(n\) denoting the number of words. Each of the following \(n\) lines contains a single word.
Example:
6 apple Apple banana BANANA banana cherry
outputFormat
Output each unique word along with its count in lexicographical order. Each line should contain the word and its frequency separated by a single space.
For the above example, the output will be:
apple 2 banana 3 cherry 1## sample
6
apple
Apple
banana
BANANA
banana
cherry
apple 2
banana 3
cherry 1
</p>