Clean & Optimized Code + Commented
\nclass Solution {\npublic:\n     bool check(string word, unordered_set<string>& dict, unordered_map<string, bool> &ump){\n        if(ump.find(word) !=  ump.end
```\nclass Solution {\npublic:\n     bool check(string word, unordered_set<string>& dict, unordered_map<string, bool> &ump){\n        if(ump.find(word) !=  ump.end()) return ump[word];\n        for(int i = 1 ; i < word.size() ; ++i) {\n            string substring = word.substr(0, i); // check for every substring\n            if(dict.count(substring)) { // if substring is pre-stored\n                string nextpart = word.substr(i); // the rest substring\n                if(dict.count(nextpart) || check(nextpart, dict, ump)) // check if the next substring is been there in our map already or using the next part we can do the same operation(recursive call) and is possible\n                {\n                    ump.insert({word, true});\n                    return true;\n                }\n            }\n        }\n       ump.insert({word, false});\n       return false;\n    }\n    \n    vector<string> findAllConcatenatedWordsInADict(vector<string>& words) {\n        vector<string> res;\n        unordered_set<string> dict(words.begin(), words.end()); // let\'s remove duplicate words first\n        unordered_map<string, bool> mp;\n        for(string word : words)\n            if(check(word, dict, mp)) res.push_back(word);\n        return res;\n    }\n};\n```
['C', 'Ordered Set']