Python Trie Way
\nclass TrieNode(object):\n    def __init__(self):\n        self.isAend = False\n        self.contains = {}\nclass MagicDictionary(object):\n    def __init__(se
```\nclass TrieNode(object):\n    def __init__(self):\n        self.isAend = False\n        self.contains = {}\nclass MagicDictionary(object):\n    def __init__(self):\n        self.root = TrieNode()\n    def addWord(self, word):\n        r = self.root\n        for chr in word:\n            if chr not in r.contains:\n                r.contains[chr] = TrieNode()\n            r = r.contains[chr]\n        r.isAend = True\n\n    def findWord(self, remain, r, word):\n        if not word:\n            return True if remain == 0 and r.isAend else False\n        for key in r.contains.keys():\n            if key == word[0]:\n                if self.findWord(remain, r.contains[key], word[1:]):\n                    return True\n            elif remain == 1:\n                if self.findWord(0, r.contains[key], word[1:]):\n                    return True\n        return False\n    def buildDict(self, dict):\n        for word in dict:\n            self.addWord(word)\n    def search(self, word):\n        return self.findWord(1, self.root, word)\n```
[]