Using Trie
\nclass Solution {\npublic:\n    class Trie\n    {\n        public:\n           Trie *child[2];\n           int val = 0;\n    };\n\n    \n    void insert(int x,
```\nclass Solution {\npublic:\n    class Trie\n    {\n        public:\n           Trie *child[2];\n           int val = 0;\n    };\n\n    \n    void insert(int x, Trie *root){\n    \t\n        Trie* curr=root;\n        for(int i=31;i>=0;i--)\n        {\n            int bit = (x >> i) & 1;\n            if(curr->child[bit] == NULL)\n                curr->child[bit] = new Trie();\n            \n            curr = curr->child[bit];\n        }\n        curr->val = x;\n        \n    }\n    \n    int findAns(int x, Trie *root)\n    {\n        Trie* curr = root;\n        for(int i=31;i>=0;i--)\n        {\n            int bit = (x >> i) & 1;\n           \n            if(curr->child[!bit]!=NULL)\n                curr = curr->child[!bit];\n           \n            else if(curr->child[bit]!=NULL)\n                curr=curr->child[bit];\n        }\n        return curr->val;  \n    }\n    \n    int findMaximumXOR(vector<int>& nums) {\n        \n        int ans = INT_MIN;\n        \n        Trie* root = new Trie();\n        \n        for(auto n:nums)\n            insert(n, root);\n        \n        \n        for(auto n:nums)\n            ans = max(ans, n ^ findAns(n, root));\n        \n        return ans;\n    }\n};\n```
[]