Python with Trie and BFS
Idea is to loop on next possible nodes (letters).\nKeeping an array of nodes in search function and updating it with next_nodes in which we store the next possi
Idea is to loop on next possible nodes (letters).\nKeeping an array of `nodes` in search function and updating it with `next_nodes` in which we store the next possible node.\nThen in the end of our search we may have more than 1 possible node, so we check if any of the node `is_word`. If yes then word is present and return `True`.\n```\nclass TrieNode:\n    def __init__(self):\n        self.is_word = False\n        self.children = {}\n\nclass WordDictionary:\n\n    def __init__(self):\n        self.root = TrieNode()\n\n    def addWord(self, word: str) -> None:\n        node = self.root\n        for ch in word:\n            if ch not in node.children:\n                node.children[ch] = TrieNode()\n            node = node.children[ch]\n        node.is_word = True\n\n    def search(self, word: str) -> bool:\n        nodes = [self.root]\n        for ch in word:\n            next_nodes = []\n            for node in nodes:\n                if ch in node.children:\n                    next_nodes.append(node.children[ch])\n                if ch == \'.\':\n                    next_nodes.extend(node.children.values())\n            nodes = next_nodes\n        \n        for node in nodes:\n            if node.is_word:\n                return True\n        \n        return False\n```\n\nIf you like the solution, up-vote would be fantastic ;)
['Breadth-First Search', 'Trie', 'Python']