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.
vector<int>matchingStrings(vector<string>stringList,vector<string>queries){//create a query mapunordered_map<string,int>queryMap;for(stringquery:queries){queryMap[query]=0;}//count each query in the stringListfor(stringstr:stringList){if(queryMap.find(str)!=queryMap.end()){queryMap[str]++;}}//create the result vector for the queries' counts.vector<int>result;for(stringquery:queries){result.push_back(queryMap[query]);}returnresult;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sparse Arrays
You are viewing a single comment's thread. Return to all comments →
Using hash map or unordered_map in c++: