#C8180. Word Length Frequencies
Word Length Frequencies
Word Length Frequencies
Given a list of words, your task is to compute the frequency of each unique word length and output the results sorted in increasing order of word length. For example, if the input is a single word "hello", the output should be "5 1" since the length is 5 and it appears once.
More formally, if you are given an integer \(N\) indicating the number of words followed by \(N\) words, let \(f(l)\) represent the number of words of length \(l\). You should output each pair \(l\ f(l)\) in ascending order of \(l\). There is no extra output apart from the required lines.
inputFormat
The input is provided via standard input (stdin) in the following format:
N word1 word2 ... wordN
Here, the first line contains an integer \(N\) which is the number of words. The following part contains \(N\) words separated by spaces or newlines.
outputFormat
Output the frequency of each word length as sorted pairs. For each unique word length, print a line with the word length and its frequency separated by a space. The pairs must be printed in increasing order of word length.
For example, if the words are: hello world coding is fun
then the output should be:
2 1 3 1 5 2 6 1## sample
1
hello
5 1
</p>