Skip to content

Latest commit

 

History

History
24 lines (15 loc) · 392 Bytes

884.md

File metadata and controls

24 lines (15 loc) · 392 Bytes

Uncommon Words from Two Sentences

Description

link


Solution

  • See Code

Code

O(n)

class Solution:
    def uncommonFromSentences(self, A: str, B: str) -> List[str]:
        cnt = collections.Counter((A + ' ' + B).split(' '))
        return [w for w, c in cnt.items() if c == 1]