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
Compare all pairs of numbers by computing their XOR and tracking the maximum. For each pair (i, j), XOR gives the combined differing bits, and the largest XOR value represents the pair with the most significant differing bits.
XOR of two numbers produces the largest value when they differ at the highest bit positions, so exhaustive comparison finds the optimal pair.
Updated Feb 2026