Created
September 29, 2018 08:41
-
-
Save kerolloz/cae0d4e4d30ce4ddff9cca3e58a355ab to your computer and use it in GitHub Desktop.
This file contains 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 (){ | |
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