884. 两句话中的不常见单词

exiaohu 于 2022-01-30 发布

题目链接:884. 两句话中的不常见单词

找到两句哈中只出现过一次的单词即可。

from collections import Counter
from typing import List


class Solution:
    def uncommonFromSentences(self, s1: str, s2: str) -> List[str]:
        return [word for word, counter in Counter(f'{s1} {s2}'.split()).items() if counter == 1]