思路是使用Counter,将字符串1和字符串2用空格分割。所有=1的就是答案。
class Solution: def uncommonFromSentences(self, s1: str, s2: str) -> List[str]: c = Counter(s1.split(" ")+s2.split(" ")) return [i for i in c if c[i] ==1]```
京公网安备 11010502049817号