python trie solution O(n)
Here I use a trie (binary tree has zero and one children)\n\nclass TrieNode():\n    def __init__(self):\n        self.one = None\n        self.zero = None\n\ncl
Here I use a trie (binary tree has zero and one children)\n```\nclass TrieNode():\n    def __init__(self):\n        self.one = None\n        self.zero = None\n\nclass Solution:\n    def findMaximumXOR(self, nums):\n        """\n        :type nums: List[int]\n        :rtype: int\n        """\n        root = TrieNode()\n        for num in nums:\n            node = root\n            for j in range (31, -1, -1):\n                tmp = num & 1 << j\n                if tmp:\n                    if not node.one:\n                        node.one = TrieNode()\n                    node = node.one\n                else:\n                    if not node.zero:\n                        node.zero = TrieNode()\n                    node = node.zero\n                    \n        ans = 0\n        for num in nums:\n            node = root\n            tmp_val = 0\n            for j in range (31, -1, -1):\n                tmp = num & 1 << j\n                if node.one and node.zero:\n                    if tmp:\n                        node = node.zero\n                    else:\n                        node = node.one\n                    tmp_val += 1 << j\n                else:\n                    if (node.zero and tmp) or (node.one and not tmp):\n                        tmp_val += 1 << j\n                    node = node.one or node.zero\n            ans = max(ans, tmp_val)\n                                                \n        return ans\n```\nAsk me if you have question or correct me if I am wrong.\n\nThanks
[]