I am working on vector of strings and map of strings and int to print a histogram.
What I need to do now is to return a count of strings, from the most frequent to the less frequent elements. This is the part of my code where I am having issues so far:
string histogram( const vector<string> &v) {
string st = "";
map<vector<string>, int> h;
for(auto ite = v.begin(); ite!= v.end(); ite++ ) {
if(h.find(v) == h.end()) {
h[v] = 1;
} else {
h[v]++;
}
}
for (auto it: h) {
st += "[" + it.first + ":" + it.second + "]";
}
return st;
}
The error I keep getting is related to this line:
st += "[" + it.first + ":" + it.second + "]";
I have been checking online how to fix this error or what I am missing for I still can't see exactly how to work with the operator for the strings.