Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
most Frequent word
#include <bits/stdc++.h> using namespace std; int main() { map<string,int> words; vector<string> word; int max = 0; int N, i; string S; cin>>N; for(i =0; i<N; i++){ cin>>S; if(words.find(S) == words.end()){ words[S] = 0; } else{ words[S]++; } } for(map<string,int>::iterator it = words.begin(); it != words.end(); ++it){ // cout<<"Key: "<<it->first<<" Value: "<< it->second<<endl; if((it->second)>max) max = it->second; } for(map<string,int>::iterator it = words.begin(); it != words.end(); ++it) if(it->second == max) word.push_back(it->first); sort(word.begin(), word.end()); reverse(word.begin(), word.end()); cout<<word[0]<<" "<<max+1<<endl; }
run
|
edit
|
history
|
help
0
volatile thread-safe object
Height of a binary tree
shared_ptr deleter
decode
Sliding Game
cynb
Graph Theory 2
ContainerVector
Deepa
SegTree