Two Unpaired Numbers
Every number in nums appears exactly twice, except for two different numbers that each appear exactly once. Return those two numbers as a list of two items in increasing order. There is a one pass solution with constant extra memory: the XOR of the whole list is the XOR of the two answers, and any 1 bit of that value tells the two apart.
Example 1
nums [1,2,1,3,2,5]
returns [3,5]
1 and 2 appear twice; 3 and 5 appear once.
Example 2
nums [4,9]
returns [4,9]
Both numbers appear once; 4 is the smaller one.
Constraints
2 <= len(nums) <= 1000 <= nums[i] <= 1000- exactly two values occur once and every other value occurs exactly twice
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.