C++ using Trie and DFS for search. easy understand solution
 struct Trie {\n         vector<Trie *> child;\n         bool isWord;\n         Trie() : isWord(false), child(vector<Trie *>(26, nullptr)) {}\n     };\n     Tri
     struct Trie {\n         vector<Trie *> child;\n         bool isWord;\n         Trie() : isWord(false), child(vector<Trie *>(26, nullptr)) {}\n     };\n     Trie *root;\n     WordDictionary() : root(new Trie()) {}\n\n    void addWord(string word) {\n        const int size_w = word.size();\n        Trie *cur = root;\n        for (int i = 0; i < size_w; i++) {\n            int index = word[i] - 'a';\n            if (!cur->child[index]) cur->child[index] = new Trie();\n            cur = cur->child[index];\n        }\n        cur->isWord = true;\n    }\n\n    bool search(string word) {\n        return search(word.c_str(), root);\n    }\n    bool search(const char *ch, TrieNode *cur) {\n        if (!cur) return false;\n        if (*ch == '\\0') return cur->isWord;\n        if (*ch != '.') {\n             return search(ch+1, cur->child[*ch - 'a']);\n        } else {\n            for (int i = 0; i <= 25; i++) {\n                if (search(ch+1, cur->child[i])) return true;\n            }\n            return false;\n        }\n    }
[]