Python Trie One Pass Through Input Array
\nclass Solution(object):\n    def findMaximumXOR(self, nums):\n        def Trie(): \n            return collections.defaultdict(Trie)\n        \n        root =
```\nclass Solution(object):\n    def findMaximumXOR(self, nums):\n        def Trie(): \n            return collections.defaultdict(Trie)\n        \n        root = Trie()\n        best = 0\n        \n        for num in nums:\n            candidate = 0\n            cur = this = root\n            for i in range(32)[::-1]:\n                curBit = num >> i & 1\n                this = this[curBit]\n                if curBit ^ 1 in cur:\n                    candidate += 1 << i\n                    cur = cur[curBit ^ 1]\n                else:\n                    cur = cur[curBit]\n            best = max(candidate, best)\n        return best\n```
[]