You are viewing a single comment's thread. Return to all comments →
Why does the following code time out on the largest few inputs? Isn't it also O(n)?
void checkMagazine(vector<string> magazine, vector<string> note) { unordered_multiset<string> magazineSet (magazine.begin(), magazine.end()); unordered_multiset<string> noteSet (note.begin(), note.end()); for (string word: note) { if(noteSet.count(word) > magazineSet.count(word)) { cout << "No" << endl; return; } } cout << "Yes" << endl; }
Seems like cookies are disabled on this browser, please enable them to open this website
Arrays
You are viewing a single comment's thread. Return to all comments →
Why does the following code time out on the largest few inputs? Isn't it also O(n)?