C++ solution || with explanatory comments
Approach\n Describe your approach to solving the problem. \n1. We will store all binary values of array\'s element in Trie.\n\n2. we know that XOR gives max val
# Approach\n<!-- Describe your approach to solving the problem. -->\n1. We will store all binary values of array\'s element in Trie.\n\n2. we know that XOR gives max value with its complement values i.e, 1^0 = 1.\n\n3. So, In trie we search complementery values as long as possible.\n\n4. Store max value in ans and return.\n\n# Complexity\n  - Time complexity\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(N)\n\n*You can better understand through code with comments*\n# Code\n```\nclass Solution {\npublic:\n    struct TrieNode {\n        //trie with max 2 child, not taking any bool or 26 size value because no need\n        TrieNode* one;\n        TrieNode* zero;\n    };\n    void insert(TrieNode* root, int n) {\n        TrieNode* curr = root;\n        for (int i = 31; i >= 0; i--) {\n            int bit = (n >> i) & 1;  //it will find 31st bit and check it is 1 or 0\n            if (bit == 0) {\n                if (curr->zero == nullptr) {   //if 0 then we will continue filling on zero side\n                    TrieNode* newNode = new TrieNode();    \n                    curr->zero = newNode;  \n                }\n                curr = curr->zero;   //increase cur to next zero position\n            }\n            else {\n                //similarly if we get 1 \n                if (curr->one == nullptr) {\n                    TrieNode* newNode = new TrieNode();\n                    curr->one = newNode;\n                }\n                curr = curr->one;\n            }\n        }\n    }\n     int findmax(TrieNode* root, int n) {\n        TrieNode* curr = root;\n        int ans = 0;\n        for (int i = 31; i >= 0; i--) {\n            int bit = (n >> i) & 1;\n            if (bit == 1) {\n                if (curr->zero != nullptr) {  //finding complement , if find 1 then we will check on zero side\n                    ans += (1 << i); //push values in ans\n                    curr = curr->zero;\n                }\n                else {\n                    curr = curr->one;  //if we don\'t get then go to one\'s side\n                }\n            }\n            else {\n                //similarly on zero side if we get 0 then we will check on 1 s side\n                if (curr->one != nullptr) {   \n                    ans += (1 << i);\n                    curr = curr->one;\n                }\n                else {\n                    curr = curr->zero;\n                }\n            }\n        }\n        return ans;\n    }\n\n    int findMaximumXOR(vector<int>& nums) {\n        int n = nums.size();\n        TrieNode* root = new TrieNode();\n        int ans = 0;\n        for (int i = 0; i < n; i++) {\n            insert(root, nums[i]);    //it will make trie by inserting values\n        }\n        for (int i = 1; i < n; i++) {\n            ans = max(ans, findmax(root, nums[i]));  //find the necessary complementory values and maximum store\n        }\n        return ans;\n    }\n};\n```
['Bit Manipulation', 'Trie', 'C++']