题解 | 小红书推荐系统

小红书推荐系统

https://www.nowcoder.com/practice/e5b39c9034a84bf2a5e026b2b9b973d0

#include <iostream>
using namespace std;
#include<string>
#include<algorithm>
#include<vector>
#include<map>
struct re{
string s;
int v;


};
bool cmp(re& a,re& b){
if(a.v!=b.v){
return a.v>b.v;
}
return a.s<b.s;



}
int main(){
map<string,int> a;
string word;
while(cin>>word)
{
a[word]++;

}

int n=a.size();
vector<re> w;
for(auto it=a.begin();it!=a.end();it++){
    if(it->second>=3){
w.push_back({it->first,it->second});
    }
}
sort(w.begin(),w.end(),cmp);

for(auto it=w.begin();it!=w.end();it++){

cout<<it->s<<endl;


}







    return 0;
}

全部评论

相关推荐

等闲_:小红书基本不区分日常和暑期,你是应届实习时间够了就有转正机会,只要部门有hc
点赞 评论 收藏
分享
01-04 11:28
已编辑
广州华立学院 Java
程序员花海:实习内容写的看起来太偏向于技术了 要结合业务 很多同学搞反了 其实业务才是最重要的 要避免这种单纯罗列技术栈的格式
简历被挂麻了,求建议
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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