421. Maximum XOR of Two Numbers in an Array Solution
My solution\n\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar findMaximumXOR = function(nums) {\n    var sum = 0;\n    var minValue = 0;\n    for
My solution\n```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar findMaximumXOR = function(nums) {\n    var sum = 0;\n    var minValue = 0;\n    for (var i = 1; i < nums.length; i++) {\n        if ((nums[minValue] ^ nums[i]) > sum ) {\n            sum = nums[minValue] ^ nums[i];\n            if (i === nums.length-1) {\n                minValue++;\n                i = minValue;\n            }\n        }else if (i === nums.length-1) {\n            minValue++;\n            i = minValue;\n        }\n    }\n    return sum;\n};\n```\nFaster Learned from [here](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/discuss/91049/Java-O(n)-solution-using-bit-manipulation-and-HashMap)\n```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar findMaximumXOR = function(nums) {\n    var max = 0;\n    var mask = 0;\n    \n    for (let i = 31; i >= 0; i--) {\n        mask = mask | ( 1 << i);\n        const set = new Set();\n        for (let n of nums) {\n            set.add(n & mask);\n        }\n        let temp = max | (1 << i);\n        for (let prefix of set) {\n            if (set.has(temp ^ prefix)) {\n                max = temp;\n                break;\n            }\n        }\n    }\n    \n    return max;\n};\n```
['JavaScript']