Skip to content

Instantly share code, notes, and snippets.

@surinoel
Created July 18, 2019 07:40
Show Gist options
  • Save surinoel/39b1e7337c563c47643583ddf78db229 to your computer and use it in GitHub Desktop.
Save surinoel/39b1e7337c563c47643583ddf78db229 to your computer and use it in GitHub Desktop.
#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