Trie solution self explanatory code
\nclass node{\n    public:\n    node*left;\n    node*right;\n    node(){\n        this->left=NULL;\n        this->right=NULL;\n    }\n};\nclass Solution {\npubl
```\nclass node{\n    public:\n    node*left;\n    node*right;\n    node(){\n        this->left=NULL;\n        this->right=NULL;\n    }\n};\nclass Solution {\npublic:\n    node*root=new node();\n    void insert(int num){\n        node*curr=root;\n        for(int i=31;i>=0;i--){\n            int mask=1<<i;\n            int ithbit=mask&num;\n            if(ithbit==0){\n                if(curr->left==NULL){\n                    curr->left=new node();\n                     curr=curr->left;\n                }else{\n                    curr=curr->left;\n                }\n            }else{\n                 if(curr->right==NULL){\n                    curr->right=new node();\n                     curr=curr->right;\n                }else{\n                    curr=curr->right;\n                }\n            }\n        }\n    \n    }\n    int search(int num){\n        int maxpossible=INT_MAX^num;\n        int ans=0;\n        node*curr=root;\n        for(int i=31;i>=0;i--){\n            int mask=1<<i;\n            int ithbit=mask&maxpossible;\n            if(ithbit==0){\n                if(curr->left==NULL){\n                    ans=ans|mask;\n                    curr=curr->right;\n                }else{\n                    curr=curr->left;\n                }\n                \n            }else{\n                if(curr->right==NULL){\n                   curr=curr->left;\n                }else{\n                    ans=ans|mask;\n                    curr=curr->right;\n                }\n            }\n        }\n        return ans;\n    }\n    void preorder(node*r){\n        if(r==NULL){\n            return;\n        }\n        if(r->left){cout<<0<<" "; preorder(r->left);}\n        if(r->right){cout<<1<<" ";preorder(r->right);}\n    }\n    int findMaximumXOR(vector<int>& nums) {\n        int n=nums.size();\n        int ans=INT_MIN;\n        // insert(5);\n        for(int i=0;i<n;i++){\n            insert(nums[i]);  \n         }\n        // preorder(root);\n        for(int i=0;i<n;i++){\n            ans=max(ans,nums[i]^search(nums[i]));\n        }\n        return ans;\n    }\n};\n```
[]