Striver's Code || Using Trie
Complexity\n- Time complexity : O(32*n) \n Add your time complexity here, e.g. O(n) \n\n\n# Code\n\nstruct Node {\n    Node* child[2];\n\n    bool containsKey(i
# Complexity\n- Time complexity : $$O(32*n)$$ \n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```\nstruct Node {\n    Node* child[2];\n\n    bool containsKey(int bit) {\n        return (child[bit] != NULL); // checks if this bit is present or not\n    }\n\n    void put(int bit, Node* node) {\n        child[bit] = node;\n    }\n\n    Node* get(int bit) {\n        return child[bit];\n    }\n};\n\nclass Trie {\nprivate:\n    Node* root;\n\npublic:\n    Trie() {\n        root = new Node();\n    }\n\n    void insert(int num) {\n        Node* node = root;\n        for(int i=31 ; i>=0 ; i--) {\n            int bit = (num>>i) & 1;\n            if(!node->containsKey(bit)) {\n                node->put(bit,new Node());\n            }\n            node = node->get(bit);\n        }\n    }\n\n    int getMax(int num) {\n        Node* node = root;\n        int maxNum = 0;\n\n        for(int i=31 ; i>=0 ; i--) {\n            int bit = (num>>i) & 1;\n            if(node->containsKey(1-bit)) {\n                maxNum = maxNum | (1<<i);\n                node = node->get(1-bit);\n            }\n            else {\n                node = node->get(bit);\n            }\n        }\n        return maxNum;\n    }\n};\n\nclass Solution {\npublic:\n    int findMaximumXOR(vector<int>& nums) {\n        Trie trie;\n        for(auto &ele:nums) {\n            trie.insert(ele);\n        }\n\n        int maxi = 0;\n        for(auto &ele:nums) {\n            maxi = max(maxi,trie.getMax(ele));\n        }\n        return maxi;\n    }\n};\n```
['C++']