You are viewing a single comment's thread. Return to all comments →
Simple and effective c++ solution:
bool ransom_note(vector<string> magazine, vector<string> ransom) { unordered_map<string, int> words; for (auto &it: magazine) words[it]++; for (auto &it: ransom) { if (words[it]>0) words[it]--; else return false; } return true; }
Seems like cookies are disabled on this browser, please enable them to open this website
Hash Tables: Ransom Note
You are viewing a single comment's thread. Return to all comments →
Simple and effective c++ solution: