✅Easy and Simple Solution With Explanation ✅ Clean Code ✅ Best Solution
\nGuy\'s if you find this solution helpful \uD83D\uDE0A, PLEASE do UPVOTE. By doing that it motivate\'s me to create more better post like this \u270D\uFE0F\nFo
\n***Guy\'s if you find this solution helpful \uD83D\uDE0A, PLEASE do UPVOTE. By doing that it motivate\'s me to create more better post like this \u270D\uFE0F***<br>\n**Follow me on LinkeDin [[click Here](https://www.linkedin.com/in/ayushluthra62/)]**\n\n# Complexity\n- Time complexity:\nbuildDict Function : O(N)\n Search Function    : O(N * 26)\n\n- Space complexity:\nO(N)\n\n# Code\n```\nclass MagicDictionary {\npublic:\nunordered_map<string,int>mapping;\n    MagicDictionary() {\n            \n    }\n    \n    void buildDict(vector<string> dictionary) {\n        for(auto i : dictionary) mapping[i]++;\n    }\n    \n    bool search(string searchWord) {\n        \n       \n    \n\n\n        // check for all the possibilites \n        // iterate over the string and put all 26 char on currentPosition and check if it is present or not \n        // if not just put the original curr back check for rest of string\n        for(int j=0;j<searchWord.length();j++){\n            char currChar = searchWord[j];\n\n            for(int i=0;i<26;i++){\n                char newChar =  (char)(\'a\'+i);\n\n                searchWord[j] =newChar;\n\n                if(currChar != newChar && mapping.find(searchWord) != mapping.end()) return true;\n            }\n            searchWord[j] = currChar;\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```\n\n\n***Guy\'s if you find this solution helpful \uD83D\uDE0A, PLEASE do UPVOTE. By doing that it motivate\'s me to create more better post like this \u270D\uFE0F***<br>\n**Follow me on LinkeDin [[click Here](https://www.linkedin.com/in/ayushluthra62/)]**
['Hash Table', 'String', 'Depth-First Search', 'Design', 'Trie', 'C++']