728x90
반응형
LeetCode-819
Most Common Word : 금지된 단어를 제외한 가장 많은 빈도의 단어 추출
Info : 대소 문자, 구두점 무시
class Solution:
def mostCommonWord(self, paragraph: str, banned: List[str]) -> str:
return Counter([word for word in re.sub("[^a-z]", ' ',paragraph.lower()).split() if word not in banned]).most_common(1)[0][0]
Result : 28 Memory: 13.9mb
반응형
'One step' 카테고리의 다른 글
[leetcode-49] Group Anagrams (0) | 2023.03.02 |
---|---|
LeetCode - Time complexity 시간 복잡도 (0) | 2023.03.02 |
[leetcode-937] Reorder_Data_in_LogFile (0) | 2023.03.01 |
[leetcode-344] ReverseString (0) | 2023.02.27 |
[leetcode-125] Palindrome + Slicing (0) | 2023.02.27 |