Build a binary trie where each number is represented by its bits from most significant to least.
For each number, traverse the trie greedily choosing the opposite bit when possible (to maximize XOR).
Insert all numbers into the trie (32 bits each).
For each number, query the trie for the maximum XOR partner.
Track the overall maximum.