Solution of 'Maps-STL' (Hackerrank)
So, here's my solution of the question- Maps-STL of Hackerrank. If you guys have any suggestions, do comment. Thank you and Happy coding.
link: https://www.hackerrank.com/challenges/cpp-maps/problem
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
int q;
cin>>q;
int a[q];
map<string,int> mark;
for(int i=0;i<q;i++){
cin>>a[i];
if(a[i]==1){
string p;
int k;
cin>>p>>k;
mark[p]+=k;
}
else if(a[i]==2){
string p;
cin>>p;
mark[p]=0;
}
else if(a[i]==3){
string p;
cin>>p;
cout<<mark[p]<<'\n';
}
}
}
Comments
Post a Comment