[Python] Solve this question in real interview with video explanation
My step by step approach to solve this question like in real interview with video explanation:\nhttps://youtu.be/zjnb7QUZMPQ\n\nIntuition: Hahsmap / Looping\n\n
My step by step approach to solve this question like in real interview with video explanation:\nhttps://youtu.be/zjnb7QUZMPQ\n\nIntuition: Hahsmap / Looping\n\n**Code**\n```\nclass MagicDictionary:\n\n    def __init__(self):\n        """\n        Initialize your data structure here.\n        """\n        self.m = collections.defaultdict(list)\n\n    def buildDict(self, dictionary: List[str]) -> None:\n        for word in dictionary:\n            self.m[len(word)] += [word]\n        \n    def search(self, searchWord: str) -> bool:\n        if len(searchWord) not in self.m: return False\n        wordList = self.m[len(searchWord)]\n        \n        for word in wordList:\n            cnt = 0\n            for i in range(len(searchWord)):\n                if searchWord[i] != word[i]: cnt += 1\n                if cnt > 1: break\n            if cnt == 1: return True           \n        return False\n```\n\nTime Complexity: O(m*n)\nSpace Complexity: O(m)\n\nFeel free to subscribe to my channel. More LeetCoding videos coming up!
['Python']