c++ trie solution using bitmasking
using brute force there is time limit exceeded (using n^2)\nso optimize using trie.\n\n\'\'\'\n\nclass TrieNode{\npublic:\n    TrieNode child[2];\n    TrieNode(
using brute force there is time limit exceeded (using n^2)\nso optimize using trie.\n\n\'\'\'\n\nclass TrieNode{\npublic:\n    TrieNode* child[2];\n    TrieNode(){\n        for(int i=0;i<2;i++) child[i]=NULL;\n    }\n};\n\nclass Trie{\npublic:\n    TrieNode *root;\n    Trie(){\n        root = new TrieNode();\n    }\nprivate:\n    void insert(int &number){\n        TrieNode *curr = root;\n        for(int i = 31;i>=0;i--){\n            int bit = (number>>i)&1;\n            if(curr->child[bit] == NULL) curr->child[bit]=new TrieNode();\n            curr = curr->child[bit];\n        }\n    }\n    int findmax(int &number){\n        TrieNode *curr = root;\n        int ans=0;\n        for(int i=31;i>=0;i--){\n            int bit = (number>>i)&1;\n            int req = 1-bit;//required opposite to make max Eg 0111^1000 = 1111\n            if(curr->child[req] != NULL){\n                ans =(ans | (1<<i));//if the required is there then we can make that bit 1\n                curr = curr->child[req];\n            }\n            else{\n                curr = curr->child[bit];\n            }\n        }\n        return ans;\n    }\npublic:\n    int insert_vec(vector<int>& nums){\n        for(int i=0;i<nums.size();i++) insert(nums[i]);\n        int maxi = INT_MIN;\n        for(int i=0;i<nums.size();i++) maxi = max(maxi,findmax(nums[i]));\n        return maxi;\n    }\n    \n};\n\n\nclass Solution {\npublic:\n    int findMaximumXOR(vector<int>& nums) {\n        Trie *trie = new Trie();\n        return trie->insert_vec(nums);;\n    }\n};
['Dynamic Programming', 'Trie', 'C', 'Bitmask', 'C++']