[Time O(n*log(n))] No Trie, Yes Binary search
Thanks to @DammitWA, it turns out that this solution does not  work and luckily passes all test cases. Testcase that disproves this approach: [1,2,18]\n\n### Id
### Thanks to @DammitWA, it turns out that this solution does not  work and luckily passes all test cases. Testcase that disproves this approach: [1,2,18]\n\n### Idea\n\nXOR of two numbers is maximized when one of the number is the bitwise flip of the other. \nFor example, XOR of 5 (101) is maximum when the other number is 2 (010).\nBased on this idea, we do binary-search of bitwise flip of each number.\nSince there may not be the exact bitwise flip number, we find the closest numbers.\nFor example, in `[3,10,5,25,2,8]`,\nthe bitwise flip of 25 (11001) is 6 (110). \nHowever, there is no 6 in the list. We try the closest numbers, which are 5 (101) and 8 (1000).\n\n### Corner Case\n\nThere is a corner case in this approach. \nIf the bitwise length of numbers in the list are all equal, the closest number always becomes the minimum number in the list.\nFor example, in `[4,5,6]`,\nthe length of the numbers in their bit representations are same: 4=100, 5=101, 6=110.\nSince the bitwise flip of each number is always smaller than 100, the closest number is always 4.\nTo compromise this, we also try the number closest to `bitwise flip + the most significant bit`.\nIn the example above, the most significant bit of numbers is 100; we add this to each bitwise flips of the numbers (11, 10, 1 -> 111, 110, 101).\n\n### Complexity\n\nTime: `O(n*log(n))`\nSpace: `O(n)`\n\n```typescript\nfunction findMaximumXOR(nums: number[]): number {\n    nums.sort((a, b) => a - b)\n    let max = 0\n    for (const num of nums) {\n        const target = flip(num)\n        const t1 = binarySearch(nums, target)\n        max = Math.max(max, nums[t1] ^ num)\n        if (1 <= t1) {\n            max = Math.max(max, nums[t1-1] ^ num)            \n        }\n\t\tconst target2 = target + Math.pow(2, Math.floor(Math.log2(num)))\n        const t2 = binarySearch(nums, target2)\n        max = Math.max(max, nums[t2] ^ num)\n        if (1 <= t2) {\n            max = Math.max(max, nums[t2-1] ^ num)            \n        }\n    }\n    return max\n};\n\nfunction binarySearch(nums: number[], target: number) {\n    let l=0\n    let r=nums.length-1\n    while (l < r) {\n        const m = Math.floor((l+r) / 2)\n        if (target <= nums[m]) {\n            r = m\n        } else {\n            l = m+1\n        }\n    }\n    return l\n}\n\nfunction flip(num: number) {\n    return parseInt(num.toString(2).split(\'\').map(b => b === \'1\' ? \'0\': \'1\').join(\'\'), 2)\n}\n```
['Binary Tree', 'TypeScript', 'JavaScript']