We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I am using c++, 5 tests didn't pass, how can I improve it?
vector<int>freqQuery(vector<vector<int>>queries){vector<int>resultFreq;unordered_map<int,int>subFinal;boolcheck;// Open the vectorfor(constauto&q:queries){//insertif(q[0]==1)subFinal[q[1]]++;// decrementif(q[0]==2){if(q[q[1]]>0)subFinal[q[1]]--;if(q[q[1]]==0)subFinal.erase(q[1]);}// findif(q[0]==3){check=true;for(constauto&[key,val]:subFinal){if(val==q[1]){check=false;break;}}if(check==false)resultFreq.push_back(1);elseresultFreq.push_back(0);}}returnresultFreq;}
Frequency Queries
You are viewing a single comment's thread. Return to all comments →
I am using c++, 5 tests didn't pass, how can I improve it?