#884

Uncommon Words from Two Sentences

easy · 75.6% accepted · 1,897 likes · top 87%

hash table · string · counting

⊣ practice⊣ open on leetcode ↗

Description

A sentence is a string of single-space separated words where each word consists only of lowercase letters.

A word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence.

Given two sentences s1 and s2, return a list of all the uncommon words. You may return the answer in any order.

Solution