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,intmark;
    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

Popular posts from this blog

Solution to the problem 'The Squid Game' form Codechef

Solution of 'Tom Riddle's Diary' (Codeforces)

Solution to the problem 'Red Light, Green Light' from Codechef