You are viewing a single comment's thread. Return to all comments →
c++ Using unordered map
unordered_map<string, int> umap; vector<int> toReturn; for(unsigned i = 0; i < queries.size(); ++i) { if(queries.at(i).at(0) == "add") { for(unsigned j = 0; j < queries.at(i).at(1).size(); ++j){ ++umap[queries.at(i).at(1).substr(0,j+1)]; } } else if(queries.at(i).at(0) == "find") { toReturn.push_back(umap[queries.at(i).at(1)]); } } return toReturn;
Seems like cookies are disabled on this browser, please enable them to open this website
Find the Running Median
You are viewing a single comment's thread. Return to all comments →
c++ Using unordered map