This question is quite easy!
We only need to input t sets of data and traverse each string. And use two counters, "suma" and "sumb", to determine the number of occurrences of letter A and letter B, and compare them.
It is worth noting that the title has already mentioned that the length of the string is 5, so we do not need to determine whether suma is equal to sumb.
Hope to see your comments!
Below is the AC code:
#include <bits/stdc++.h>
using namespace std;
int t;
int main() {
cin >> t;
while(t--) {
string s;
cin >> s;
int suma = 0, sumb = 0;
for(int i = 0; i < s.length(); i++) {
if(s[i] == 'A') suma++;
else sumb++;
}
if(suma > sumb) cout << "A" << endl;
else cout << "B" << endl;
}
return 0;
}