A2 online judge 193. Omar Loves Candies, Again Solution
Problem Link: https://a2oj.com/p?ID=193
Solution:
Solution:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include<bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { int i, j, c=0, maxc=0; string s; char ch; cin>>s; for(i=0; i<(int)s.size(); i++) { c=0; for(j=0; j<(int)s.size(); j++) { if(s[i]==s[j]) c++; } if(maxc < c) { maxc = c; ch = s[i]; } if(maxc == c) { if(ch > s[i]) ch = s[i]; } } cout<<maxc<<" "<<ch<<endl; } } |
This comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete