Single Number III
Medium · bit manipulation
A festival hands out numbered wristbands. Every wristband number was scanned at the gate exactly twice (once in, once out), except for two numbers that were scanned only once, because those guests lost their wristbands.
Given the list nums of scanned numbers (in no particular order), return the two numbers that appear exactly once, as a list of two integers in ascending order.
Examples
Example 1
Input: nums = [4, 9, 4, 6]
Output: [6, 9]
4 appears twice. 9 and 6 appear once, and in ascending order they are [6, 9].
Example 2
Input: nums = [-3, 8, 2, 8, 2, 5]
Output: [-3, 5]
8 and 2 are paired, leaving -3 and 5.
Example 3
Input: nums = [0, 1]
Output: [0, 1]
Constraints
- 2 <= len(nums) <= 3 * 10^4
- -10^9 <= nums[i] <= 10^9
- Exactly two different values appear once; every other value appears exactly twice.