Simplest Solution possible in C++ [Explanation Given]
\n// Trie Solution provided\nclass TrieNode{\n  public:\n    bool isEnd;\n\tvector<TrieNode*> dict;\n    TrieNode(){\n        isEnd = false;\n        dict.resiz
```\n// Trie Solution provided\nclass TrieNode{\n  public:\n    bool isEnd;\n\tvector<TrieNode*> dict;\n    TrieNode(){\n        isEnd = false;\n        dict.resize(26,nullptr);\n    }\n};\nclass WordDictionary {\npublic:\n    /** Initialize your data structure here. */\n    TrieNode* root;\n    WordDictionary() {\n        root = new TrieNode();\n    }\n    \n    /** Adds a word into the data structure. */\n\t// Addition of word in the trie is fairly simple.\n\t// If you are not able to understand it, then solve the below question first :\n\t// https://leetcode.com/problems/implement-trie-prefix-tree/\n    void addWord(string word) {\n        TrieNode* itr = root;\n        for(int i=0;i<word.length();i++){\n            if(itr->dict[word[i]-\'a\']==nullptr){\n                itr->dict[word[i]-\'a\'] = new TrieNode();\n            }\n            itr = itr->dict[word[i]-\'a\'];\n        }\n        itr->isEnd = true;\n    }\n\n\n\t// Recursive function for searching the string in the trie.\n    bool func(TrieNode* root, string word, int pos){\n\t\t// When pos becomes equal to length of the word i.e. we are at the end of the string.\n        if(word.length()==pos){\n\t\t\t// If the string is present in the trie then "root" will be at the end of the trie.\n            if(root->isEnd)\n                return true;\n            return false;\n        }\n\t\t// If the character is not \'.\' then it is fairly simple.\n\t\t// We just need to check whether the word[pos] is present in the trie or not.\n        if(word[pos]!=\'.\'){\n            if(root->dict[word[pos]-\'a\']!=nullptr)\n                return func(root->dict[word[pos]-\'a\'], word,pos+1);\n            else\n                return false;\n        }\n        else{\n\t\t\t// Now, if we encounter \'.\' then we need to check every possible alphabet i.e. from a-z\n\t\t\t// If we find any alphabet which is present in the trie,\n\t\t\t// then we have to make the recursive call to the function with now --> pos + 1.\n\t\t\t// If we encounter null node then we will continue and check the rest of the alphabets.\n            for(int i=0;i<26;i++){\n                if(root->dict[i]==nullptr)\n                    continue;\n                else{\n                    if(func(root->dict[i],word,pos+1))\n                        return true;\n                }\n            }\n        }\n\t\t// If after checking everything, we don\'t find the alphabet in the trie ->\n        return false;\n    }\n    bool search(string word) {\n        return func(root, word, 0);\n    }\n};\n\n/**\n * Your WordDictionary object will be instantiated and called as such:\n * WordDictionary* obj = new WordDictionary();\n * obj->addWord(word);\n * bool param_2 = obj->search(word);\n */\n```\n\nIf  you are still facing problems, then do ask your questions int the **comment** section.\nIf you have any other efficient ways, then do mention it in the **comment** section.\nHappy Coding :)
['Backtracking', 'Trie', 'C++']