Your question is Top N Word Counting. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Medium's article tools need to identify the most frequently used words in a paragraph. Given a paragraph and an integer n, return the top n words ranked by descending frequency. Break ties alphabetically.
Words are contiguous sequences of English letters. Matching is case-insensitive, and punctuation is ignored. Return each result as a two-element list containing the lowercase word and its frequency. If n exceeds the number of distinct words, return every distinct word.
paragraph, a non-empty string, and n, a positive integer.[word, frequency] pairs ordered by decreasing frequency, then alphabetically for equal frequencies.def top_n_words(paragraph, n):