C++ O(31 * N) using Bit Manipulation
\nclass Solution {\npublic:\n    int xor_arr(vector <int> & nums){\n        int mx = 0;\n        //Max Value\n        int mask = 0;\n        // Prefix Mask -> 1
```\nclass Solution {\npublic:\n    int xor_arr(vector <int> & nums){\n        int mx = 0;\n        //Max Value\n        int mask = 0;\n        // Prefix Mask -> 10000, 11000, 11100, 11110, 11111\n        set <int> se;\n        \n        for(int bit=30;bit >=0;--bit){\n            mask |= (1 << bit);\n            for(int i=0;i<nums.size();++i){\n                se.insert(nums[i] & mask);\n                //this is important such that binary representation of num (from nums) only includes till\n                //ith bit.\n            }\n            \n            int newMax = mx | (1 << bit);\n            // Check whether we can improve mx value by turning on the ith bit in mx\n            // such that newMax is obtained\n            // if a^b = x then a^x = b;\n            for(auto prefix : se){\n                \n               if(se.count(newMax ^ prefix)){\n                    mx = newMax;\n                    break;\n                }\n            }\n            \n            se.clear();\n        }\n        return mx;\n    }\n    int findMaximumXOR(vector<int>& nums) {\n        return xor_arr(nums);\n    }\n};\n```
['Bit Manipulation', 'C', 'Ordered Set', 'C++']