Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
XOR all elements to get a ^ b where a and b are the two unique numbers. Find the rightmost set bit in a ^ b to use as a splitter, then partition all numbers into two groups by that bit. XOR within each group isolates one unique number per group.
The differing bit guarantees a and b land in separate groups, while all duplicate pairs stay together within the same group and cancel via XOR.
Updated Feb 2026