[C++] Intuitive &  Simple Beginner Friendly TRIE Solution
Intuitive Trie Solution, the insert operation is same as the basic trie insert operation. For searching just replace each character of searchWord one-by-one and
Intuitive Trie Solution, the insert operation is same as the basic trie insert operation. For searching just replace each character of `searchWord` one-by-one and check whether we are not relacing the original character (since we need to change 1 character).\n\n# Time Complexity\n- Building the Trie: `O(n * m)`, where n is the number of words in the dictionary and m is the average length of words.\n- Searching for Possible Matches: `O(m * 26) ~ O(m)`, where m is the length of the search word.\n\n# Space Complexity\n- Trie Data Structure: `O(n * m)`, where n is the number of words in the dictionary and m is the average length of words.\n- Recursive Calls (Call Stack): `O(m)`, where m is the length of the search word.\n\n\n```\nstruct Node{\n    Node* links[26];\n    bool flag=false;\n\n    bool containsKey(char ch){\n        return links[ch-\'a\']!=NULL;\n    }\n    void put(char ch, Node* node){\n        links[ch-\'a\']=node;\n    }\n    Node* get(char ch){\n        return links[ch-\'a\'];\n    }\n    void setEnd(){\n        flag=true;\n    }\n    bool isEnd(){\n        return flag;\n    }\n};\n\nclass MagicDictionary {\nprivate: \n    Node* root;\n\n    void insert(string word){\n        Node* node=root;\n        for(int i=0;i<word.length();i++){\n            if(!node->containsKey(word[i])){\n                node->put(word[i], new Node());\n            }\n            node=node->get(word[i]);\n        }\n        node->setEnd();\n    }\n\n    bool searchUtil(string word){\n        Node* node=root;\n        for(int i=0;i<word.length();i++){\n            if(!node->containsKey(word[i])){\n                return false;\n            }\n            node=node->get(word[i]);\n        }\n        return node->isEnd();\n    }\n\npublic:\n    MagicDictionary() {\n        root=new Node();\n    }\n    \n    void buildDict(vector<string> dictionary) {\n        for(string s:dictionary){\n            insert(s);\n        }\n    }\n    \n    bool search(string word) {\n        int n=word.length();\n        for(int i=0;i<n;i++){\n            char original=word[i];\n            for(int j=0;j<26;j++){\n                char replacement = \'a\' + j;\n                if(replacement != original){\n                    word[i] = replacement;\n                    if(searchUtil(word)){\n                        return true;\n                    }\n                }\n            }\n            word[i]=original;\n        }\n\n        return false;\n    }\n};\n```
['String', 'Design', 'Trie', 'C++']