Leetcode 920 Solution
This article provides solution to leetcode question 920 (uncommon-words-from-two-sentences)
Access this page by simply typing in "lcs 920" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/uncommon-words-from-two-sentences
Solution
class Solution(object):
def uncommonFromSentences(self, A, B):
"""
:type A: str
:type B: str
:rtype: List[str]
"""
m = collections.defaultdict(int)
for word in A.split():
m[word] += 1
for word in B.split():
m[word] += 1
return [word for word, cnt in m.items() if cnt == 1]