[C++] Trie Solution | Intuition | O(nlog(m))
APPROACH :\n\n We need a data structure through which we can do the following 2 jobs easily :\n      1. Insert all the elements of the array into the data struc
**APPROACH :**\n\n* We need a data structure through which we can do the following 2 jobs easily :\n      1. Insert all the elements of the array into the data structure. \n      2. Given a Y, find maximum XOR of Y with all numbers that have been inserted.\n* So, we can use trie.\n* Every bit in a number has 2 possibilities : ```0``` & ```1```.\n* So, we have 2 pointers in every Trie Node : child[0] ---> pointing to ```0``` bit & child[1] ---> pointing to ```1``` bit.\n* We insert all the elements into the Trie :\n          1. We use a bitset of size 32 (```bitset<32> bs```), go from the most significant bit (MSB) to the least significant bit (LSB).\n          2. We start at the root of the Trie & check if it\'s child[0] or child[1] is present (not ```NULL```), depending upon the current bit ```bs[j]``` at each bit of the number.\n          3. If it\'s present, we go to it\'s child, if not, we create a new Node at that child (0 bit or 1 bit) and move to it\'s child.\n* We traverse the array & for each element we find the maximum ```XOR``` possible with any other element in the array using the Trie :\n         1. We start at the root of the Trie and at the MSB of the number & we initialize ```ans = 0```.\n         2. If the current bit is set, we go to ```child[0]``` to check if it\'s not NULL. If it\'s not NULL, we add ```1<<i``` to ```ans```.\n         3. If it\'s not set, we go to ```child[1]``` to see it\'s not NULL, if it\'s not NULL, we add ```1<<i``` to ```ans```.\n* After checking the maximum XOR possible (with any other element) at each element of the array, we update the result to maximum of previous result & the current result.\n* Finally return the maximum possible XOR.\n\n*I tried my best to explain the approavh here, please refer to the code for better clarity*\n\n**Time Complexity :** O(n*x*logm) - ```n = nums.size()```, ```m = *max_element(nums.begin(), nums.end())```.\n\n**Code :**\n```\nclass TrieNode{\npublic:\n    TrieNode *child[2];\n    \n    TrieNode(){\n        this->child[0] = NULL; //for 0 bit \n        this->child[1] = NULL; //for 1 bit\n    }\n};\nclass Solution {\n    TrieNode *newNode;\n    \n    void insert(int x){   //to insert each element into the Trie\n        TrieNode *t = newNode;\n        bitset<32> bs(x);\n        \n        for(int j=31; j>=0; j--){\n            if(!t->child[bs[j]]) t->child[bs[j]] = new TrieNode(); //start from the MSB =, move to LSB using bitset\n            t = t->child[bs[j]];\n        }    \n    }\n    \npublic:\n    int findMaximumXOR(vector<int>& nums) {\n        newNode = new TrieNode();\n        for(auto &n : nums) insert(n); //insert all the elements into the Trie\n        \n        int ans=0; //Stores the maximum XOR possible so far\n        for(auto n : nums){\n            ans = max(ans, maxXOR(n));  //updates the ans as we traverse the array & compute max XORs at each element.\n        }\n        return ans;\n    }\n    \n    int maxXOR(int n){\n        TrieNode *t = newNode;\n        bitset<32> bs(n);\n        int ans=0; \n        for(int j=31; j>=0; j--){\n            if(t->child[!bs[j]]) ans += (1<<j), t = t->child[!bs[j]]; //Since 1^0 = 1 & 1^1 = 0, 0^0 = 0\n           \n            else t = t->child[bs[j]];\n        }\n        return ans;\n    }\n};\n```\n\n**Do upvote if you like my solution & explanation :)**\n
['Trie', 'C', 'C++']