A warehouse inventory scan produces a log of m SKU codes. Every SKU code in the log appears exactly twice, except for exactly two SKU codes, which each appear exactly once (they were scanned before a shelf reshuffle interrupted the second pass).
Given the log, identify those two SKU codes.
Line 1: an integer m, the number of entries in the log.
Line 2: m space-separated non-negative integers, the scanned SKU codes.
The two SKU codes that appear exactly once, printed in ascending order, separated by a single space.
Example 1
Input
6 2 7 4 2 9 4
Expected
7 9
Explanation
Every SKU appears twice except 7 and 9, which appear once; sorted ascending gives 7 9.
Example 2
Input
4 1 3 1 10
Expected
3 10
Explanation
1 appears twice; 3 and 10 each appear once, so the answer is 3 10.
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 →