Solution
C++ []\nclass MagicDictionary {\n public:\n  void buildDict(vector<string> dictionary) {\n    for (const string& word : dictionary)\n      for (int i = 0; i < w
```C++ []\nclass MagicDictionary {\n public:\n  void buildDict(vector<string> dictionary) {\n    for (const string& word : dictionary)\n      for (int i = 0; i < word.length(); ++i) {\n        const string replaced = getReplaced(word, i);\n        dict[replaced] = dict.count(replaced) ? \'*\' : word[i];\n      }\n  }\n  bool search(string searchWord) {\n    for (int i = 0; i < searchWord.length(); ++i) {\n      const string replaced = getReplaced(searchWord, i);\n      if (dict.count(replaced) && dict[replaced] != searchWord[i])\n        return true;\n    }\n    return false;\n  }\n private:\n  unordered_map<string, char> dict;\n\n  string getReplaced(const string& s, int i) {\n    return s.substr(0, i) + \'*\' + s.substr(i + 1);\n  }\n};\n```\n\n```Python3 []\nclass MagicDictionary:\n\n    def __init__(self):\n        self.countDict = {}\n\n    def buildDict(self, dictionary: List[str]) -> None:\n        for word in dictionary:\n            if len(word) not in self.countDict: self.countDict[len(word)] = []\n            self.countDict[len(word)].append(word)\n\n    def isOneOff(self, word, searchWord) -> bool:\n        numDiffs = 0\n        for i in range(len(word)):\n            if word[i] != searchWord[i]: numDiffs += 1\n            if numDiffs > 1: return False\n        return numDiffs == 1\n\n    def search(self, searchWord: str) -> bool:\n        if len(searchWord) not in self.countDict: return False\n        candidates = self.countDict[len(searchWord)]\n        for c in candidates:\n            if self.isOneOff(c, searchWord): return True\n        return False\n```\n\n```Java []\nclass MagicDictionary {\n    private HashMap<Integer, ArrayList<String>> lenMap;\n    public MagicDictionary() {\n        lenMap = new HashMap<>();\n    }\n    public void buildDict(String[] dictionary) {\n        lenMap.clear();\n        for(String word: dictionary){\n            if(!lenMap.containsKey(word.length())){\n                lenMap.put(word.length(), new ArrayList<>());\n            }\n            lenMap.get(word.length()).add(word);\n        }\n    }\n    public boolean search(String searchWord) {\n        if(!lenMap.containsKey(searchWord.length())){\n            return false;\n        }\n        ArrayList<String> arr = lenMap.get(searchWord.length());\n        for(String word: arr){\n            if(checkAlmostSame(searchWord, word)){\n                return true;\n            }\n        }\n        return false;\n    }\n    private boolean checkAlmostSame(String searchWord, String word){\n        boolean foundDiff = false;\n        for(int i = 0; i < word.length(); i++){\n            if(word.charAt(i) != searchWord.charAt(i)){\n                if(foundDiff == true){\n                    return false;\n                } else {\n                    foundDiff = true;\n                }\n            }\n        }\n        return foundDiff;\n    }\n}\n```\n
['C++', 'Java', 'Python3']