You are viewing a single comment's thread. Return to all comments →
My solution was almost identical but used pre-decrements to reduce the if statement
bool ransom_note(vector<string> magazine, vector<string> ransom) { map<string, int> words; for(string& word : magazine) words[word]++; for(string& word : ransom) if(--words[word] < 0) 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 →
My solution was almost identical but used pre-decrements to reduce the if statement