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
Initialize XOR with n (the array length). Then XOR every index 0..n-1 and every array value together. All present numbers pair with their index and cancel out, leaving only the missing number.
XOR-ing indices 0..n with all array values creates matched pairs for every number except the missing one, and paired XOR cancels to zero.
Updated Feb 2026