Simple Trie Solution
\n\n# Complexity\n- Time complexity:O(n32)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(n32)\n Add your space complexity here, e.g. O(n) 
\n\n# Complexity\n- Time complexity:O(n*32)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n*32)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass TrieNode{\n    public:\n    char ch;\n    TrieNode * children[2];\n    bool isTerminal;\n\n    TrieNode(char ch){\n       this->ch=ch;\n       for(int i=0;i<2;i++)\n       children[i]=NULL;\n\n       isTerminal=false;\n    }\n\n\n};\nclass Solution {\npublic:\nstring getBitString(int x){\n    string s="";\n    while(x>0){\n        if(x%2==0){\n            s.push_back(\'0\');\n\n        }\n        else s.push_back(\'1\');\n        x/=2;\n    }\n\n    while(s.size()<32){\n        s.push_back(\'0\');\n    }\n\n    reverse(s.begin(),s.end());\n\n    return s;\n}\n    int findMaximumXOR(vector<int>& nums) {\n         \n\n         vector<string> bits;\n\n         for(auto i:nums){\n            bits.push_back(getBitString(i));\n         }\n\n      \n\n        TrieNode * root=new TrieNode(\'\\0\');\n\n        for(auto i:bits){\n          TrieNode * crawler=root;\n\n          for(auto j:i){\n            if(crawler->children[j-\'0\']==NULL)\n            crawler->children[j-\'0\']=new TrieNode(j);\n\n            crawler=crawler->children[j-\'0\'];\n          }\n\n          crawler->isTerminal=true;\n        }\n\n        int ans=0;\n\n        for(auto i:bits){\n            TrieNode * crawler=root;\n            int res=0;\n\n            for(auto j:i){\n               auto k= (j==\'0\')?\'1\':\'0\';\n\n               if(crawler->children[k-\'0\']!=NULL){\n                crawler=crawler->children[k-\'0\'];\n                res=res*2;\n                res+=1;\n               }\n               else{\n                crawler=crawler->children[!(k-\'0\')];\n                res=res*2;\n                res+=0;\n               }\n            }\n\n            ans=max(ans,res);\n        }\n\n\n        return ans; \n    }\n};\n```
['String', 'Trie', 'C++']