C++ | Map and Bitmask
Code\n\nclass MagicDictionary {\n    map<pair<string, string>, int> Map;\npublic:\n    MagicDictionary() {\n        \n    }\n    \n    void buildDict(vector<str
# Code\n```\nclass MagicDictionary {\n    map<pair<string, string>, int> Map;\npublic:\n    MagicDictionary() {\n        \n    }\n    \n    void buildDict(vector<string> dictionary) {\n        for(string word: dictionary) {\n            for(int i = 0; i < word.length(); i++) {\n                Map[{word.substr(0, i), word.substr(i + 1)}] |= 1 << (word[i] - \'a\');\n            }\n        }\n    }\n    \n    bool search(string searchWord) {\n        for(int i = 0; i < searchWord.length(); i++) {\n            if(Map.find({searchWord.substr(0, i), searchWord.substr(i + 1)}) != Map.end()) {\n                if(Map[{searchWord.substr(0, i), searchWord.substr(i + 1)}] xor (1 << (searchWord[i] - \'a\'))) {\n                    return true;\n                }\n            }\n        }\n        return false;\n    }\n};\n\n/**\n * Your MagicDictionary object will be instantiated and called as such:\n * MagicDictionary* obj = new MagicDictionary();\n * obj->buildDict(dictionary);\n * bool param_2 = obj->search(searchWord);\n */\n```
['Hash Table', 'String', 'Bit Manipulation', 'Design', 'C++']