• + 0 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;
    }