Spring Hire Sale
Limited Time Deal: Unlock all premium questions for over 30% off
08
:
03
:
09
:
39
Top 10 Words
Given a string of text, find the ten most frequently occurring words. A word is defined as any maximal sequence of consecutive alphabetic characters (a-z, A-Z). Comparison is case-insensitive (treat uppercase and lowercase letters as equal). Non-alphabetic characters (digits, punctuation, whitespace) serve as word separators.
Return a list of [word, frequency] pairs, where word is the lowercased form and frequency is the count as a string. The list should be sorted in descending order by frequency. If two words have the same frequency, sort them in ascending alphabetical order. Return at most 10 entries. If fewer than 10 distinct words exist, return all of them.
...