forked from dscgecbsp/Hacktoberfest-2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaps-STL.cpp
More file actions
33 lines (29 loc) · 725 Bytes
/
Maps-STL.cpp
File metadata and controls
33 lines (29 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
Maps-STL | CPP | HackerRank | C++ | https://www.hackerrank.com/challenges/cpp-maps/problem | By- Arwaz Khan
Maps are a part of the C++ STL.
Maps are associative containers that store elements formed by a combination of a key value and a mapped value, following a specific order.
*/
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
int q,a;cin>>q;string n;
map<string,int>m;
for(int i=0;i<q;i++)
{
cin>>a>>n;int mrk;
if(a==1)
{
cin>>mrk;m[n]+=mrk;
}
else if(a==2) m.erase(n);
else cout<<m[n]<<endl;
}
return 0;
}