C++ || Trie Solution || 264 ms Solution
Runtime: 264 ms, faster than 34.25% of C++ online submissions for Add and Search Word - Data structure design.\nMemory Usage: 45.4 MB, less than 55.28% of C++ o
***Runtime: 264 ms, faster than 34.25% of C++ online submissions for Add and Search Word - Data structure design.\nMemory Usage: 45.4 MB, less than 55.28% of C++ online submissions for Add and Search Word - Data structure design.***\n```\nclass TrieNode{\n    public:\n        vector<TrieNode*> next;\n        bool isWord = false;\n        TrieNode(){\n            next.resize(26, NULL);\n        }\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    void addWord(string word) {\n        TrieNode* current = root;\n        for(char ch:word){\n            if(!current->next[ch - \'a\']){\n                current->next[ch - \'a\'] = new TrieNode();\n            }\n            current = current->next[ch - \'a\'];\n        }\n        current->isWord = true;\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 searchHelper(word, root);\n    }\nprivate:\n    \n    bool searchHelper(string word, TrieNode* current) {\n        for(int i = 0; i < word.size(); i++){\n            char ch = word[i];\n            if(ch != \'.\'){\n                if(!current->next[ch - \'a\']) \n                    return false;\n                current = current->next[ch - \'a\'];\n            }\n            else{\n                for(int j = 0; j < 26; j++){\n                    if(current->next[j] && searchHelper(word.substr(i + 1), current->next[j])){\n                        return true;\n                    }\n                }\n                return false;\n            }\n        }\n        return current->isWord;\n    }\n};\n```
['C', 'C++']