{"id":"dycnwr","deleted":false,"future_paste":false,"expired":false,"language":"text","created_at":"2026-11-05 13:15:00","expires_at":null,"content":"Most Common Word (LeetCode 819) - interview notes\n\nApproach\n1. Lowercase the paragraph and pull words with a regex [a-z]+ (this strips \"!?',;.\" punctuation in one pass).\n2. Put the banned list in a set for O(1) lookups.\n3. Count with a hash map and return the max key.\n\nPython:\n\n    import re\n    from collections import Counter\n\n    def mostCommonWord(paragraph, banned):\n        ban = set(banned)\n        words = re.findall(r\"[a-z]+\", paragraph.lower())\n        return Counter(w for w in words if w not in ban).most_common(1)[0][0]\n\nComplexity: O(P + B) time, O(P + B) space.\nEdge cases to say out loud: punctuation glued to words (\"ball,\"), mixed case,\na banned word that is also the most frequent, a single-word paragraph.\n\nFollow-up: return the top k words (heap of size k, O(N log k)).\n\nDisclosure: I work on Linkjob AI. If you want practice with live feedback,\nsee Linkjob AI copilot: https:\/\/www.linkjob.ai\/\n"}