https://leetcode-cn.com/problems/words-frequency-lcci/
直接用哈希表实现
class WordsFrequency {
unordered_map<string,int> dict;//哈希表
public:
WordsFrequency(vector<string>& book) {
for(auto &word:book)
{
dict[word]++;//对应的词数目加一次
}
}
int get(string word) {
return dict[word];//返回word出现的次数
}
};