Python implementation using dictionary
Simple Python implementation using dictionary\n ```\n class MagicDictionary:\n    def init(self):\n        self.dict = {}\n        self.word = set()\n    def bu
Simple Python implementation using dictionary\n ```\n class MagicDictionary:\n    def __init__(self):\n        self.dict = {}\n        self.word = set()\n    def buildDict(self, dictionary: List[str]) -> None:\n        # SC: O(n) # TC: O(nm)\n        for word in dictionary:\n            for i in range(len(word)):\n\t\t\t# building word templating to store as key, counting the number of template as value\n                template = word[:i] + \'*\' + word[i+1:]\n                self.dict[template] = 1 + self.dict.get(template,0)\n                self.word.add(word)\n    def search(self, searchWord: str) -> bool:\n        # TC: O(m)  SC: O(1)\n        for i in range(len(searchWord)):\n            template = searchWord[:i] + \'*\' + searchWord[i+1:]\n            if template in self.dict:\n                if searchWord not in self.word:\n                    return True\n                else:\n\t\t\t\t# if the given word is in the dictionary, make sure there are more than 2 counts for the template\n                    if self.dict[template] >= 2:\n                        return True\n        return False\n    \n# Your MagicDictionary object will be instantiated and called as such:\n# obj = MagicDictionary()\n# obj.buildDict(dictionary)\n# param_2 = obj.search(searchWord)
['Python', 'Python3']