Write count_words(words) to return a map of how many times each word appears.
count_words({"cat", "dog", "cat"})→{'cat': 2, 'dog': 1}count_words({})→{}map<string, int> count_words(const vector<string> &words)#include <map>
#include <string>
#include <vector>
using namespace std;
map<string, int> count_words(const vector<string> &words) {
map<string, int> seen;
for (const string &w : words) {
// your code here: add 1 to this word's count
}
return seen;
}
Run tries the examples. When they look right, Submit.