A speech coach wants to know which word a speaker leaned on too much. Write most_common_word(text) that returns the word that turns up most often in text. A word is an unbroken run of letters made as long as possible: any other character (a space, digit, punctuation mark or apostrophe) ends it. Capitals are ignored when counting and the word is returned in lowercase. If several words share the top count, return the one that comes first alphabetically; if text contains no words at all, return "".
Examples
Input: text = "The cat and the hat. THE end!"
Output: "the"
Input: text = "a b b a"
Output: "a"
Explanation: "a" and "b" both appear twice; "a" comes first alphabetically.
Input: text = ""
Output: ""
Constraints
- Target: O(n) time plus sorting the distinct words
Goals
- Tokenise text into words without regex
- Normalise case before counting
- Break ties deterministically