Mental Model
Use XOR to cancel out pairs and isolate two unique numbers by splitting the array into two groups based on a set bit.
Analogy: Imagine you have pairs of socks mixed in a pile, except two socks are unique. By shaking the pile and separating socks by a unique feature (like color), you can find the two unmatched socks.
Array: [2, 3, 7, 9, 2, 3] XOR all: 2 ⊕ 3 ⊕ 7 ⊕ 9 ⊕ 2 ⊕ 3 = 7 ⊕ 9 = 14 (binary 1110) Split by rightmost set bit (bit 1): Group 1: elements with bit 1 set -> 2, 3, 7, 2, 3 Group 2: elements with bit 1 not set -> 9 XOR Group1: 2⊕3⊕7⊕2⊕3 = 7 XOR Group2: 9 Result: unique elements are 7 and 9
