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 |