As reported: Datadog Senior Frontend code screen (Apr 2025), problem 1 — a warm-up.
This is LeetCode 819 — Most Common Word. Our write-up: /most-common-word.
Given a string paragraph and a list of banned words, return the most frequent word that is not banned. Words are case-insensitive and the answer is returned in lowercase; punctuation (!?',;.) separates words. The answer is guaranteed to exist and to be unique.
Example 1
paragraph = "Bob hit a ball, the hit BALL flew far after it was hit."
banned = ["hit"]
Output: "ball"
Example 2
paragraph = "a.", banned = []
Output: "a"
Constraints: 1 ≤ paragraph.length ≤ 1000; it contains English letters, spaces and !?',;.; 0 ≤ banned.length ≤ 100; banned words are lowercase letters.
Code runner format: one JSON value per line: paragraph, banned. Implement mostCommonWord(paragraph, banned).