Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Complete the checkMagazine function below.
- void checkMagazine(vector<string> magazine, vector<string> note) {
- std::map<std::string, int> mapM, mapN;
- for(auto itM : magazine) {
- if ( mapM.find(itM) == mapM.end() ) {
- mapM.insert(std::make_pair(itM, 1));
- }
- else {
- mapM[itM]++;
- }
- }
- for(auto itN : note) {
- if ( mapN.find(itN) == mapN.end() ) {
- mapN.insert(std::make_pair(itN, 1));
- }
- else {
- mapN[itN]++;
- }
- }
- for(auto it : mapN) {
- // Note에 있는게 Magazine에 없다면 No
- auto itM = mapM.find(it.first);
- if ( itM == mapM.end() ) {
- cout << "No" << endl;
- return;
- }
- else {
- if ( it.second > itM->second ) {
- cout << "No" << endl;
- return;
- }
- }
- }
- cout << "Yes" << endl;
- return;
- }
Add Comment
Please, Sign In to add comment