You are viewing a single comment's thread. Return to all comments →
here is my solution.
using namespace std;
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */
int queries, q; int y; string x; map<string, int> m; map<string, int>::iterator itr = m.begin(); cin >> queries; for (int i = 0; i < queries; i++) { cin >> q; if (q==1) { cin >> x; cin >> y; m[x] +=y ; } else if(q==2) { cin >> x; m.erase(x); } else if (q==3) { cin >> x; if(m.find(x) != m.end()) { cout << m[x] << endl; } else { cout << 0 << endl; } } } return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Maps-STL
You are viewing a single comment's thread. Return to all comments →
here is my solution.
include
include
include
include
include
include
include
using namespace std;
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */
}