Java O(n) solution using Trie
\n    class Trie {\n        Trie[] children;\n        public Trie() {\n            children = new Trie[2];\n        }\n    }\n    \n    public int findMaximumXO
```\n    class Trie {\n        Trie[] children;\n        public Trie() {\n            children = new Trie[2];\n        }\n    }\n    \n    public int findMaximumXOR(int[] nums) {\n        if(nums == null || nums.length == 0) {\n            return 0;\n        }\n        // Init Trie.\n        Trie root = new Trie();\n        for(int num: nums) {\n            Trie curNode = root;\n            for(int i = 31; i >= 0; i --) {\n                int curBit = (num >>> i) & 1;\n                if(curNode.children[curBit] == null) {\n                    curNode.children[curBit] = new Trie();\n                }\n                curNode = curNode.children[curBit];\n            }\n        }\n        int max = Integer.MIN_VALUE;\n        for(int num: nums) {\n            Trie curNode = root;\n            int curSum = 0;\n            for(int i = 31; i >= 0; i --) {\n                int curBit = (num >>> i) & 1;\n                if(curNode.children[curBit ^ 1] != null) {\n                    curSum += (1 << i);\n                    curNode = curNode.children[curBit ^ 1];\n                }else {\n                    curNode = curNode.children[curBit];\n                }\n            }\n            max = Math.max(curSum, max);\n        }\n        return max;\n    }\n```
[]