Last active
February 26, 2021 21:43
-
-
Save gtindo/dbcd3683af2c3bbd0ca7f8c20479fcca to your computer and use it in GitHub Desktop.
occ.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main(){ | |
//freopen("input.txt", "r", stdin); | |
string word; | |
map<string, int> occ; | |
string max_w; | |
int max_occ = 0; | |
while(cin >> word){ | |
if(occ.count(word)){ | |
occ[word] += 1; | |
}else{ | |
occ[word] = 1; | |
} | |
if(occ[word] > max_occ){ | |
max_occ = occ[word]; | |
max_w = word; | |
} | |
} | |
cout << max_w << endl; | |
cout << max_occ << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment