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
Insert numbers into a 0/1 bit trie. For each new number, greedily choose opposite bits to maximize xor at highest positions first.
A 1 in a higher bit contributes more than all lower bits, so greedy choice of opposite child at each level maximizes total xor.
Updated Feb 2026