Pretty efficient | Using Trie | CodeDominar Solution
Code\n\nclass TrieNode:\n    def __init__(self):\n        self.children = {}\n        self.is_word = False\n        \nclass WordDictionary:\n\n    def __init__(
# Code\n```\nclass TrieNode:\n    def __init__(self):\n        self.children = {}\n        self.is_word = False\n        \nclass WordDictionary:\n\n    def __init__(self):\n        self.root = TrieNode()\n\n    def addWord(self, word: str) -> None:\n        curr = self.root\n        for w in word:\n            if w not in curr.children:\n                curr.children[w] = TrieNode()\n            curr = curr.children[w]  \n        curr.is_word = True    \n\n    def search(self, word: str) -> bool:\n        stack = [(self.root,0)]\n        while stack:\n            curr,idx = stack.pop()\n            if idx == len(word):\n                if curr.is_word:\n                    return True\n            elif word[idx] == \'.\':\n                for child in curr.children.values():\n                    stack.append((child,idx+1))\n            elif word[idx] in curr.children:\n                stack.append((curr.children[word[idx]], idx+1))\n        return False\n        \n```
['Hash Table', 'Trie', 'Python', 'Python3']