#327 · Bit manipulation · Intermediate · 75 XP · about 14 min
In the list nums, every value appears exactly twice, except two different values that appear once each. Write find_two(nums) that returns those two values as a list, smaller first.
The real goal is to do it with a fixed, small amount of extra memory however long the list is: no dictionary, set or counter that grows with the list, and no sorting a copy. The tests can only check the answer, but this is the skill the problem is here to teach.
find_two([4, 1, 2, 1, 2, 7]) # returns [4, 7] find_two([10, -3]) # returns [-3, 10] find_two([5, 9, 5, 0, 9, 8]) # returns [0, 8]
2 <= len(nums) <= 200,000-10**9 <= nums[i] <= 10**9First solves only, ranked by stars and then time.