C++ Easy hashing || In search_word function replace each char with all of 26 chars || Explained
Complexity\n- Time complexity:\nO(n * m)-> for build_dictionary function,n is the number of words to be inserted into the data structure and m is the size of th
# Complexity\n- Time complexity:\nO(n * m)-> for **build_dictionary** function,n is the number of words to be inserted into the data structure and m is the size of that word. But as it is given that the maximum size of any word can be 100 so m can be neglected and it can be considered as O(n * 100) ~= O(N).\n \nO(n)-> for **searchWord** function, where n is the length of that word\n\n- Space complexity:\nO(n), unordered_set is used to store the words available in the dictionary\n\n# Code\n```\nclass MagicDictionary {\npublic:\n    unordered_set<string>us;\n\n    MagicDictionary() {\n        \n    }\n    \n    void buildDict(vector<string> dictionary) {\n        us.insert(dictionary.begin(), dictionary.end());\n    }\n    \n    bool search(string searchWord) {\n        for(int i = 0; i<searchWord.size(); i++){\n            char org = searchWord[i];\n            for(int k = 0; k<26; k++){\n                int newchar = \'a\'+k;\n                if(newchar == org)continue;\n                searchWord[i]=newchar;\n                if(us.count(searchWord)){\n                    return true;\n                }\n            }\n            searchWord[i] = org;\n        }\n\n        return false;\n    }\n};\n```
['Hash Table', 'String', 'C++']