Dashboard
LC #260
Single Number III
Pattern · ?AmazonGoogle
Problem
Two elements appear once, all others appear twice. Find those two elements.
Constraints
- 2 ≤ n ≤ 3 × 10⁴
- -2³¹ ≤ nums[i] ≤ 2³¹ − 1
- Exactly two elements appear once; all others appear twice
- O(1) extra space required
Example
- Input
- nums = [1, 2, 1, 3, 2, 5]
- Output
- [3, 5]
- Why
- 3 and 5 appear once. All others appear twice. XOR all → 3^5, then split
Spot the pattern
Which pattern cracks it?
Hints
One at a time