Description
Given an array where every element appears twice except for two, find those two single numbers. Use bit manipulation.
Examples
Input:
nums = [1,2,1,3,2,5]Output:
[3,5]Explanation:
3 and 5 appear once each.
Input:
nums = [1]Output:
[1]Explanation:
Edge case with a single-element array.
Input:
nums = [4,1,2,1,2,3,8,4]Output:
[3,8]Explanation:
In this array, 4 appears twice (positions 0 and 7), 1 appears twice (positions 1 and 3), and 2 appears twice (positions 2 and 4). Only 3 and 8 appear exactly once each, so they are the two single numbers the task requires find.
Constraints
- •
2 ≤ nums.length ≤ 3 * 10⁴