C++ from Brute Force To using Trie Data Structure
Brute Force [ Don\'t Submit this Solution , it will give Time Limit Exeeded ]\n\n\nclass Solution {\npublic:     \n    int findMaximumXOR(vector<int>& nums) {\n
***Brute Force*** [ Don\'t Submit this Solution , it will give Time Limit Exeeded ]\n```\n\nclass Solution {\npublic:     \n    int findMaximumXOR(vector<int>& nums) {\n        int n = nums.size();\n        int res = 0;\n        for (int i = 0; i < n-1; i++) {\n            for (int j = i+1; j < n; j++) {\n                int curr = nums[i] ^ nums[j];\n                if (curr > res)\n                    res = curr;\n            }\n        }\n        return res;        \n    }\n};\n\n```\n\n***Using Trie Data Structure***\n```\nclass trieNode{\npublic:\n    trieNode *left;\n    trieNode *right;\n};\n\n/*\n \n _insert() function is used to insert the binary digits in Binary Search Tree\n The main approach will be\n 1] If the binary digit is \'0\' , then add it to the left\n 2] If the binary digit is \'1\' , then add it to the right\n \n*/\n\ntrieNode* _insert(int value, trieNode* head){\n    trieNode* cur = head;\n    for(int i = 31; i>=0; i--){\n        int bit  = (value>>i)&1;\n        if(bit == 0){  \n            if(!cur->left)\n                cur->left = new trieNode();\n            cur = cur->left;\n        }\n        else{\n            if(!cur->right)\n                cur->right = new trieNode();\n            cur = cur->right;\n        }\n    }\n    return head;\n}\n\n\nclass Solution {\npublic:\n    int xorVal(trieNode* head, vector<int> & nums){\n        int maxVal = INT_MIN;\n\n        for(int j = 0; j<nums.size();j++){\n            int curXor = 0;\n            int value = nums[j];\n            trieNode* cur = head;\n\n            for(int i = 31; i>=0; i--){\n                int bit  = (value>>i)&1;\n                if(bit == 0){\n                    if(cur->right){\n                        curXor += pow(2,i);\n                        cur = cur->right;\n                    }\n                    else\n                        cur = cur->left;\n                }\n                else{\n                    if(cur->left){\n                        curXor += pow(2,i);\n                        cur = cur->left;\n                    }\n                    else\n                        cur = cur->right;\n                }\n            }\n            maxVal = max(maxVal, curXor);\n        }\n        return maxVal;\n    }\n\n                                      \n    int findMaximumXOR(vector<int>& nums) {\n        trieNode* head = new trieNode();\n        \n        for(int j = 0; j<nums.size();j++)\n            head = _insert(nums[j], head);\n\n        return xorVal(head, nums);\n    }\n};\n```
['Bit Manipulation', 'C']