0%

HackerRank Set And Map 1.Ransom Note

題目連結:Hash Tables: Ransom Note | HackerRank

這APCS應該不會考吧?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void checkMagazine(vector<string> magazine, vector<string> note) {
unordered_map<string,int> m,n;
for(auto a:magazine){
m[a]++;
}
for(auto a:note){
n[a]++;
}

for(auto a:n){
if(m[a.first]<n[a.first]){
cout<<"No\n";
return;
}
}
cout<<"Yes\n";
}