[Java] O(n) solution with Chinese explanation video
Video:\nhttps://youtu.be/blsm1fA9JHQ\n\n/*\n    [3, 10, 5, 25, 2, 8] = [00011, 01010, 00101, 11001, 00010, 01000]\n    a^b=c, a^c=b,\n    a^b=max, a^max=b\n    
Video:\nhttps://youtu.be/blsm1fA9JHQ\n```\n/*\n    [3, 10, 5, 25, 2, 8] = [00011, 01010, 00101, 11001, 00010, 01000]\n    a^b=c, a^c=b,\n    a^b=max, a^max=b\n    mask = 10000 -> [00000, 00000, 00000, 10000, 00000, 00000], maximum = 10000 ? true \n    mask = 11000 -> [00000, 01000, 00000, 11000, 00000, 01000], maximum = 11000 ? true\n    mask = 11100 -> [00000, 01000, 00100, 11000, 00000, 01000], maximum = 11100 ? true\n    mask = 11110 -> [00010, 01010, 00100, 11000, 00010, 01000], maximum = 11110 ? false -> maximum = 11100\n    mask = 11111 -> [00011, 01010, 00101, 11001, 00010, 01000], maximum = 11101 ? false -> maximum = 11100\n    maximum = 11100 = 28\n    \n*/\nclass Solution {\n    public int findMaximumXOR(int[] nums) {\n        int maximum = 0;\n        int mask = 0;\n        for(int i = 30; i >= 0; i--) {\n            int one = 1 << i;\n            mask = mask | one;\n            HashSet<Integer> set = new HashSet<>();\n            for(int num : nums) set.add(mask & num);\n            for(int val : set) {\n                if(set.contains(val ^ (maximum | one))) {\n                    maximum = maximum | one;\n                    break;\n                }\n            }\n        }\n        return maximum;\n    }\n}\n```
[]