Two C++ solutions, Hash Table / Trie
Solution 1. Hash Table\n\nclass MagicDictionary {\npublic:\n    /** Initialize your data structure here. */\n    MagicDictionary() {}\n    \n    /** Build a dic
**Solution 1.** Hash Table\n```\nclass MagicDictionary {\npublic:\n    /** Initialize your data structure here. */\n    MagicDictionary() {}\n    \n    /** Build a dictionary through a list of words */\n    void buildDict(vector<string> dict) {\n        for(auto x: dict) m[x.size()].push_back(x);\n    }\n    \n    /** Returns if there is any word in the trie that equals to the given word after modifying exactly one character */\n    bool search(string word) {\n        for(auto x: m[word.size()])\n            if(oneEditDistance(x, word)) return true;\n        return false;\n    }\n    \nprivate:\n    unordered_map<int, vector<string>>m;\n    bool oneEditDistance(string& a, string& b){\n        int diff = 0;\n        for(int i = 0; i < a.size() && diff <= 1; i++)\n            if(a[i] != b[i]) diff++;\n        return diff == 1;\n    }\n};\n```\n***\n**Solution 2.** Trie\n```\nclass MagicDictionary {\npublic:\n    /** Initialize your data structure here. */\n    MagicDictionary() {\n        root = new TrieNode();\n    }\n    \n    /** Build a dictionary through a list of words */\n    void buildDict(vector<string> dict) {\n        for(auto x: dict) buildTrie(x);\n    }\n    \n    /** Returns if there is any word in the trie that equals to the given word after modifying exactly one character */\n    bool search(string word) {\n        TrieNode* p = root;\n        int diff = 0;\n        for(int i = 0; i < word.size(); i++){\n            char c = word[i];\n            for(int j = 0; j < 26; j++){\n                if(p->next[j] == p->next[c - 'a']) continue;\n                if(p->next[j] && find(p->next[j], word.substr(i + 1))) return true;\n            }\n            if(p->next[c - 'a']) p = p->next[c - 'a'];\n        }\n        return false;\n    }\n\nprivate:\n    struct TrieNode{\n        bool isWord;\n        TrieNode* next[26];\n        TrieNode():isWord(false){\n            memset(next, NULL, sizeof(next));\n        }\n    };\n    TrieNode* root;\n    \n    void buildTrie(string s){\n        TrieNode* p = root;\n        for(auto c: s){\n            if(!p->next[c - 'a']) p->next[c - 'a'] = new TrieNode();\n            p = p->next[c - 'a'];\n        }\n        p->isWord = true;\n    }\n    \n    bool find(TrieNode* p, string s){\n        for(auto c: s)\n            if(p->next[c - 'a']) p = p->next[c - 'a'];\n            else return false;\n        return p->isWord;\n    }\n};\n```
['Hash Table', 'Trie', 'C++']