Python O(n) by Trie with binary notation [w/ Comment]
\nPython O(n) by Trie with binary notation\n\n---\n\nImplementation\n\n\nclass Solution(object):\n    def findMaximumXOR(self, nums):\n        \n        trie = 
\nPython O(n) by Trie with binary notation\n\n---\n\n**Implementation**\n\n```\nclass Solution(object):\n    def findMaximumXOR(self, nums):\n        \n        trie = {}\n        \n        # ------------------------------\n        \n        def update_trie(x):\n            # update trie with binary representation of x\n            \n            cur = trie\n            for bit in format(x, \'032b\'):\n                \n                if bit not in cur:\n                    cur[bit] = {}\n                cur = cur[bit]\n                \n            cur[\'value\'] = x\n            \n            return\n        \n        # ------------------------------\n             \n        def best_match(x):\n            # try to match with complement of x as much as possible\n            \n            # recall that for xor opertator\n            # 1 xor 0 = 1\n            # 0 xor 1 = 1\n            # 0 xor 0 = 1 xor 1 = 0\n            \n            cur = trie\n            for bit in format(x, \'032b\'):\n                \n                rev = \'0\' if bit == \'1\' else \'1\'\n                if rev in cur:\n                    cur = cur[rev]\n                else:\n                    cur = cur[bit]\n                    \n            return cur[\'value\']\n        \n        # ------------------------------\n        \n        for x in nums:\n            update_trie(x)\n        \n        max_xor = 0\n        for x in nums:\n            \n            # update global maximal xor result\n            max_xor = max( max_xor, x ^ best_match(x) )\n         \n        return max_xor\n```
['Trie', 'Iterator', 'Python', 'Python3']