[Python 3] - Trie - Simple Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(N*K)$$ with N is the number of word and K is length of each word\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(N*K)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass TrieNode:\n\n    def __init__(self):\n        self.children = collections.defaultdict(TrieNode)\n        self.is_end = False\n\n\nclass MagicDictionary:\n\n    def __init__(self):\n        self.trie = TrieNode()\n        \n\n    def buildDict(self, dictionary: List[str]) -> None:\n        for word in dictionary:\n            cur = self.trie\n            for ch in word:\n                cur = cur.children[ch]\n            cur.is_end = True\n        \n\n    def search(self, searchWord: str) -> bool:\n        n = len(searchWord)\n        def dfs(root: TrieNode, cnt: int, i: int) -> bool:\n            if cnt > 1 or i == n: return cnt == 1 and root.is_end\n            return any([dfs(root.children[c], cnt + int(c != searchWord[i]), i + 1) for c in root.children])\n        \n        return dfs(self.trie, 0, 0)\n# Your MagicDictionary object will be instantiated and called as such:\n# obj = MagicDictionary()\n# obj.buildDict(dictionary)\n# param_2 = obj.search(searchWord)\n```
['String', 'Trie', 'Python3']