Skip to content

Commit 8616b79

Browse files
author
Partho Biswas
committed
no message
1 parent 0e6d417 commit 8616b79

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ I have solved quite a number of problems from several topics. See the below tabl
230230
|35| **[678. Valid Parenthesis String](https://tinyurl.com/y9a3g9kq)** | [Python](https://tinyurl.com/wu6rdaw/678_Valid_Parenthesis_String.py), [Swift](https://tinyurl.com/wuja3c4/678_Valid_Parenthesis_String.swift) | [Art 1](https://tinyurl.com/yad2akx6), [Art 2](https://tinyurl.com/y4odwzll), [Art 3](https://tinyurl.com/y7lkgfom), [Art 4](https://tinyurl.com/ycxpeyzn) | Medium | Super tricky. Much check again |
231231
|36| **[273. Integer to English Words](https://tinyurl.com/y7pps4u9)** | [Python](https://tinyurl.com/wu6rdaw/273_Integer_to_English_Words.py), [Swift](https://tinyurl.com/wuja3c4/273_Integer_to_English_Words.swift) | | Hard | MUST check again |
232232
|37| **[763. Partition Labels](https://tinyurl.com/yapt4n6v)** | [Python](https://tinyurl.com/wu6rdaw/763_Partition_Labels.py), [Swift](https://tinyurl.com/wuja3c4/763_Partition_Labels.swift) | | Medium | |
233+
|38| [819. Most Common Word](https://tinyurl.com/ydhwgc33) | [Python](https://tinyurl.com/wu6rdaw/819_Most_Common_Word.py), [Swift](https://tinyurl.com/wuja3c4/819_Most_Common_Word.swift) | [Art 1](https://tinyurl.com/y7u4pzeu) | Easy | |
233234

234235

235236
</p>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import re
2+
3+
class Solution(object):
4+
def mostCommonWord(self, paragraph, banned):
5+
"""
6+
:type paragraph: str
7+
:type banned: List[str]
8+
:rtype: str
9+
"""
10+
ban = set(banned)
11+
words = re.findall(r'\w+', paragraph.lower())
12+
return collections.Counter(w for w in words if w not in ban).most_common(1)[0][0]
13+
14+
15+
"""
16+
bannedSet - for quering
17+
18+
split the paragraph and generate only a list of lowercase words
19+
20+
21+
"""

0 commit comments

Comments
 (0)