Hashset-based Python O(n) solution with explanatory comments.
```\nclass Solution(object):\n    def findMaximumXOR(self, nums):\n        """\n        :type nums: List[int]\n        :rtype: int\n        """\n        best = 
```\nclass Solution(object):\n    def findMaximumXOR(self, nums):\n        """\n        :type nums: List[int]\n        :rtype: int\n        """\n        best = 0\n        mask = 0\n        for i in range(31, -1, -1): # O(n) for each bit. Going highest to lowest ensures we find max.\n            mask = mask | (1 << i)\n            s = {n & mask for n in nums} # fill a set full of prefixes of all the nums\n            \n            # The best known so far is only a prefix, but that\'s definitely the prefix we want\n            # because 2^n > 2^(n-1) + ... 2^0. Ideally we can set the ith bit too, so try. If\n            # some prefix ^ some other prefix = guess, then we\'re gucci because that prefix is\n            # possible with the given numbers. Equivalently guess ^ some prefix = other prefix,\n            # which we can check faster because of the magic of hash sets.\n            guess = best | (1 << i)\n            for prefix in s:\n                if guess ^ prefix in s:\n                    best = guess\n                    break\n                    \n        return best
[]