Skip to content

Instantly share code, notes, and snippets.

@kerolloz
Created September 29, 2018 08:41
Show Gist options
  • Save kerolloz/cae0d4e4d30ce4ddff9cca3e58a355ab to your computer and use it in GitHub Desktop.
Save kerolloz/cae0d4e4d30ce4ddff9cca3e58a355ab to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int main (){
int n;cin >> n;
for (int i = 0; i < n; ++i) {
string s;
cin >> s;
sort(s.begin(), s.end());
reverse(s.begin(), s.end());
//cout << s << endl;
map<char, int> chars;
int max = 0;
chars.clear();
char ans;
for(int j = 0; j < s.size(); j++) {
chars[s[j]]++;
if(chars[s[j]] >= max) {max = chars[s[j]]; ans = s[j];}
}
cout << max << " " << ans << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment