819-Most-Common-Word

Sat 17 May 2025

https://leetcode.com/problems/most-common-word

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def mostCommonWord(self, paragraph: str, banned: List[str]) -> str:
    banned = set(banned)
    words = re.findall(r'\w+', paragraph.lower())
    return Counter(word for word in words if word not in banned).most_common(1)[0][0]
new Solution().mostCommonWord()

Score: 5

Category: leetcode