Created
July 18, 2019 07:40
-
-
Save surinoel/39b1e7337c563c47643583ddf78db229 to your computer and use it in GitHub Desktop.
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 <string> | |
#include <vector> | |
#include <iostream> | |
using namespace std; | |
int alpha[26]; | |
int main(void) { | |
ios_base::sync_with_stdio(false); | |
cin.tie(nullptr); | |
string s; | |
while (getline(cin, s)) { | |
for (int i = 0; i < s.size(); i++) { | |
alpha[s[i] - 'a'] += 1; | |
} | |
} | |
vector<int> ans; | |
int maxv = -1; | |
for (int i = 0; i < 26; i++) { | |
if (maxv < alpha[i]) { | |
maxv = alpha[i]; | |
ans = vector<int>(); | |
ans.push_back(i); | |
} | |
else if (maxv == alpha[i]) { | |
ans.push_back(i); | |
} | |
} | |
for (auto c : ans) { | |
cout << (char)('a' + c); | |
} | |
cout << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment