HTMLify
LeetCode - Uncommon Words from Two Sentences - Python
Views: 334 | Author: abh
1 2 3 4 5 6 7 8 9 10 11 12 | class Solution: def uncommonFromSentences(self, s1: str, s2: str) -> List[str]: uncommon_words = [] s1 = s1.split() s2 = s2.split() for word in s1: if s1.count(word) == 1 and word not in s2: uncommon_words.append(word) for word in s2: if s2.count(word) == 1 and word not in s1: uncommon_words.append(word) return uncommon_words |