43. Word Frequency
EasyStringHash MapSorting
Count how often each word appears (case-insensitive). Print words sorted by decreasing count, then alphabetically, as 'word count'.
Input format
A single line of words separated by spaces.
Output format
One 'word count' per line.
Example 1
Input
the cat and the hat
Output
the 2 and 1 cat 1 hat 1
Example 2
Input
Apple apple APPLE banana
Output
apple 3 banana 1
Constraints
1 ≤ words ≤ 10⁴
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…