You are given two sentences, each a sequence of lowercase words separated by single spaces. Consider all words from both sentences together. A word is uncommon if it appears exactly once in this combined collection (so it is in one sentence, once, and nowhere else).
Print all uncommon words in ascending lexicographic order. If there are none, print an empty line.
Line 1: the first sentence (space-separated lowercase words). Line 2: the second sentence (space-separated lowercase words).
One line: the uncommon words in ascending lexicographic order, space-separated. If there are none, print an empty line.
a-z.Example 1
Input
the cat sat the dog ran
Expected
cat dog ran sat
Explanation
Combined counts: 'the' twice; 'cat','sat','dog','ran' once each. The words appearing exactly once, sorted, are 'cat dog ran sat'.
Example 2
Input
apple apple banana
Expected
banana
Explanation
'apple' appears twice, 'banana' once. Only 'banana' is uncommon.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →