C++ | Trie | Easy Solution
\nclass MagicDictionary {\npublic:\n   \n    class Trie{\n        public:\n        Trie *child[26];\n        bool isEnd;\n        Trie()\n        {\n           
```\nclass MagicDictionary {\npublic:\n   \n    class Trie{\n        public:\n        Trie *child[26];\n        bool isEnd;\n        Trie()\n        {\n            isEnd=false;\n            for(int i=0;i<26;i++)\n                child[i]=NULL;\n        }\n    };\n    Trie *root=new Trie();\n    MagicDictionary() {\n    \n    }\n    \n    void buildDict(vector<string> dictionary) {\n     \n        for(string s:dictionary)\n        {\n        Trie *node=root;      \n            for(int i=0;i<s.size();i++)\n            {\n                if(!node->child[s[i]-\'a\'])\n                {\n                    node->child[s[i]-\'a\']=new Trie();\n                }\n                node=node->child[s[i]-\'a\'];\n            }\n            node->isEnd=true;\n        }\n    }\n    bool check(string s)\n    {\n        Trie *node=root;\n        for(int i=0;i<s.size();i++)\n        {\n            if(node->child[s[i]-\'a\']==NULL)\n                return false;\n            node=node->child[s[i]-\'a\'];\n        }\n        return node->isEnd;\n    }\n    bool search(string searchWord) {\n       \n        \n        string s=searchWord;\n        int n=searchWord.size();\n        for(int i=0;i<n;i++)\n        {\n            for(int j=0;j<26;j++)\n            {\n                if(\'a\'+j==searchWord[i])\n                    continue;\n                s[i]=\'a\'+j;\n                if(check(s))\n                {\n                    return true;\n                }\n            }\n            s[i]=searchWord[i];\n        }\n        return false;\n    }\n};\n\n/**\n * Your MagicDictionary object will be instantiated and called as such:\n * MagicDictionary* obj = new MagicDictionary();\n * obj->buildDict(dictionary);\n * bool param_2 = obj->search(searchWord);\n */\n```
['Trie', 'C']