Problem Link : Make Palindrome Category : Add Hoc Contest : DSA Coding Contest - January '24
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl '\n'
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
cout.precision(12);
bool FILEIO = 1;
if (FILEIO and fopen("in.txt", "r")) {
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
}
int tc;
cin >> tc;
for (int tcase = 1; tcase <= tc; tcase++) {
int n; string s;
cin >> n >> s;
vector<int> counters(26);
for (char ch : s) {
counters[ ch - 'a' ]++;
}
int odds = 0;
for (int x : counters) {
odds += x % 2;
}
cout << max(0LL, odds - 1) << endl;
}
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.