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#include<iostream> #include<string> #include<map> using namespace std; int main(){ int t; cin >> t; while(t--){ long long n; cin >> n; string s; cin >> s; map<char,long long> m; long long maxfreq = -1; for(long long i = 0; i < n; i++){ m[s[i]]++; maxfreq = max(maxfreq,m[s[i]]); } if(maxfreq > (n/2)){ cout << (n - (n-maxfreq)*2) << endl; } else cout << n%2 << endl; } return 0; }