Easy to understand C++ solution
\nclass TrieNode{\n    int val;\n    TrieNode* binary[2];\n    \n  public:\n    \n    TrieNode()\n    {\n        binary[0] = binary[1] = NULL;\n        \n    }\
```\nclass TrieNode{\n    int val;\n    TrieNode* binary[2];\n    \n  public:\n    \n    TrieNode()\n    {\n        binary[0] = binary[1] = NULL;\n        \n    }\n    \n    ~TrieNode()\n    {\n        if(binary[0])\n            delete(binary[0]);\n        if(binary[1])\n            delete(binary[1]);\n    }\n    \n    void insert(int n)\n    {\n        TrieNode* curr = this;\n        for(int i=30;i>=0;i--)\n        {\n            bool bit = n & (1<<i);\n            // cout<<bit<<endl;\n            if(!(curr->binary[bit]))\n                curr->binary[bit] = new TrieNode();\n            curr = curr->binary[bit];                \n        }\n        curr->val = n;\n    }\n    \n    int getOpposite(int n)\n    {\n        TrieNode* curr = this;\n        for(int i=30;i>=0;i--)\n        {\n            bool bit = n & (1<<i);\n            if(curr->binary[!bit])\n                curr = curr->binary[!bit];\n            else \n                curr = curr->binary[bit];\n        }\n        return curr->val;\n    }\n};\n\n\nclass Solution {\npublic:\n    int findMaximumXOR(vector<int>& nums) {\n        TrieNode* root = new TrieNode();\n        for(int n:nums)\n            root->insert(n);\n        int res=0;\n        for(int n:nums)\n            res = max(res,n^root->getOpposite(n));\n        return res;\n    }\n    \n};\n```
[]