You are viewing a single comment's thread. Return to all comments →
Here's my C++ solution.
#include <unordered_map> #include <iostream> #include <sstream> #include <string> using namespace std; int main() { string input; getline(cin, input); int n = stoi(input); unordered_map<string, int> umap; for (int i = 0; i < n; i++) { string localInput; getline(cin, localInput); string name; int phone; istringstream iss(localInput); if (iss >> name >> phone) umap[name] = phone; } while (1){ string query; getline(cin, query); if (query.empty()) break; if (umap.find(query) != umap.end()) cout << query << "=" << umap[query] << endl; else cout << "Not found" << endl; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 8: Dictionaries and Maps
You are viewing a single comment's thread. Return to all comments →
Here's my C++ solution.