C++ trie solution
\nclass WordDictionary {\npublic:\n\n    /** Initialize your data structure here. */\n    WordDictionary() {\n        this->is_leaf = false;\n        for(int i=
```\nclass WordDictionary {\npublic:\n\n    /** Initialize your data structure here. */\n    WordDictionary() {\n        this->is_leaf = false;\n        for(int i=0; i<26; i++)\n            this->children[i] = NULL;\n    }\n    \n    /** Adds a word into the data structure. */\n    void addWord(string word) {\n        WordDictionary* root = this;\n        for (int i=0;i<word.length();i++)\n        {\n            int index = word[i] - \'a\';\n            if (root->children[index] == NULL)\n                root->children[index] = new WordDictionary();\n            root = root->children[index];\n        }\n        root->is_leaf = true;\n    }\n    \n   \n    /** Returns if the word is in the data structure. A word could contain the dot character \'.\' to represent any one letter. */\n    bool search(string word) {\n        return helper(word, this);\n    }\n    \n    \nprivate:\n    bool is_leaf;\n    WordDictionary* children[26];\n    \n    bool helper(string subword, WordDictionary* ptr)\n    {\n        for(int i=0;i<subword.length();i++)\n        {\n            if (subword[i] == \'.\')\n            {\n                for (int j=0;j<26;j++)\n                {\n                    if(ptr->children[j]) {\n                        if (helper(subword.substr(i+1), ptr->children[j]))\n                            return true;\n                    }\n                }\n\n            }\n            else\n            {\n                int index = subword[i] - \'a\';\n                if (!ptr->children[index])\n                    return false;\n                ptr = ptr->children[index];\n                continue;\n            }\n            return false;\n        }\n        if (ptr->is_leaf)\n            return true;\n        return false;\n    }\n};\n```
['C']