Word Frequency
Medium · Text Processing · tr · sort · uniq
Problem
words.txt holds words separated by spaces, possibly across several lines.
Print the two most frequent words, most frequent first, in the format uniq -c produces (a right-aligned count, then the word).
Approaches
- tr, sort, uniq -c, sort -rn, head
Related problems
Start free on Cariara · Coding problems · System design studio