We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Anyone failing Test case #1 (in C++ at least), be aware N is not the maximum amount of queries that can be made. It could give you 5 definitions but send you 10 queries. This worked for me:
int n;
string name;
long num;
cin >> n;
cin.ignore();
map <string, long> pBook;
for (int i = 0; i < n; i++) {
cin >> name;
cin >> num;
pBook[name] = num;
}
while(cin >> name) {
if (pBook.find(name) != pBook.end()) {
cout << name << "=" << pBook.find(name)->second << endl;
} else {
cout << "Not found" << endl;
}
}
Day 8: Dictionaries and Maps
You are viewing a single comment's thread. Return to all comments →
Anyone failing Test case #1 (in C++ at least), be aware N is not the maximum amount of queries that can be made. It could give you 5 definitions but send you 10 queries. This worked for me: