LeetCode 819 Most Common Word

LeetCode 819 Most Common Word Problem

Download Code
class Solution(object):
    def mostCommonWord(self, paragraph, banned):
        :type paragraph: str
        :type banned: List[str]
        :rtype: str
        # https://leetcode.com/problems/most-common-word/discuss/193268/python-one-liner
        banned = set(banned)
        count = collections.Counter(word for word in re.split('[ !?\',;.]',
                                    paragraph.lower()) if word)
        return max((item for item in count.items() if item[0] not in banned),
Download Most Common Word.py

List of all Most Common Word problems

Leetcode 819 Most Common Word problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.

Feedback is the most important part of any website.

If you have any query, suggestion or feedback, Please feel free to contact us.