LeetCode面试题 16.02: 单词频率

First. Problem’s Description

Second. Problem’s Solution

We can simply use a unordered_map to solve this problem, which core is powered by Hash
By the way, the default initial value is 0 0 0

Three. Code For Solution

class WordsFrequency {
   
private:
    unordered_map<string, int> ump;
public:
    WordsFrequency(vector<string>& book) {
   
        for(auto it: book)  ump[it]++;            
    }
    
    int get(string word) {
   
        return ump[word];
    }
};

Four. Processing Results

全部评论

相关推荐

qq乃乃好喝到咩噗茶:院校后面加上211标签,放大加粗,招呼语也写上211
点赞 评论 收藏
分享
05-30 12:03
山西大学 C++
offer来了我跪着接:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务