classSolution: defuncommonFromSentences(self, A, B): """ :type A: str :type B: str :rtype: List[str] """ ans = [] setA = set(A.split()) setB = set(B.split()) dictA = collections.Counter(A.split()) dictB = collections.Counter(B.split()) for k, v in dictA.items(): if v == 1and k notin setB: ans.append(k) for k, v in dictB.items(): if v == 1and k notin setA: ans.append(k) return ans