You are given a string S containing only lowercase characters. You can rearrange the string and you have to print minimum number of characters needed(can be 0) to make it palindrome.
Sample Input:
3
1
a
9
abbbcbddd
6
abcdef
Sample Output:
0
2
5
#include <bits/stdc++.h>
using namespace std;
int main(){
int t{};
cin>>t;
while(t–){
int n{};
cin >> n;
char a[n];
int count[26]{},odds{};
for (int i = 0; i < n;i++){
cin >> a[i];
count[(int)a[i] - 97]++;
}
for (int i = 0; i < 26;i++){
if(count[i]%2!=0){
odds++;
}
}
if(odds>=1){
cout << odds - 1 << endl;
}
else{
cout << 0 << endl;
}
}
}