반응형
Problem : leetcode.com/problems/most-common-word/
Solution:
class Solution:
def mostCommonWord(self, paragraph: str, banned: List[str]) -> str:
words = []
processing = re.sub('[^a-zA-Z]',' ',paragraph).lower().split()
for word in processing:
if not word in banned:
words.append(word)
return collections.Counter(words).most_common(1)[0][0]
댓글