Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Uncommon Words from Two Sentences

XPChallenge Points: 10
levelLevel: Easy

A sentence is a string containing words separated by single spaces, and each word consists only of lowercase English letters.
A word is considered uncommon if:
• It appears exactly once in one of the two sentences,
• and does not appear in the other sentence.
Given two sentences s1 and s2, return a list of all uncommon words.
You may return the answer in any order.

Example 1:

Input: s1 = "this apple is sweet" s2 = "this apple is sour"

Output: ["sweet", "sour"]

Example 2:

Input: s1 = "apple apple" s2 = "banana"

Output: ["banana"]

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result