Last Submissions | ||||||
---|---|---|---|---|---|---|
Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
| discuss11577 - | Accepted | C++11 | 0.000 | 0.000 | 314 | 59 secs ago |
Problem: 11577
Suggest:
- Use array 'a' -> 'z' to count frequency of word (so easy => i think the problem lv1 not lv2)
#include<bits/stdc++.h>
using namespace std;
int t;
string s;
int a['z'+1];
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> t; getline(cin, s);
while(t--){
getline(cin,s);
for(int i=0; s[i]; i++)
if ('a' <= s[i] && s[i] <= 'z')
a[s[i]]++;
else
if ('A' <= s[i] && s[i] <= 'Z')
a[s[i]+32]++;
int MAX = a['a'];
for(int i='b'; i<='z'; i++)
MAX = max(MAX, a[i]);
for(int i='a'; i<='z'; i++)
if (MAX == a[i]) cout<<char(i);
cout<<"\n";
for(int i='a'; i<='z'; i++) a[i]= 0;
}
}
No comments:
Post a Comment