My issue
answer is same but after submission it is giving wrong answer
My code
#include <bits/stdc++.h>
using namespace std;
int alpha(int* a,int& n){
for(int i=0;i<26;i++){
if(a[i]==2){
return n-2;
}
if(a[i]==n){
return 0;
}
}
return -1;
}
int main() {
int t,n;
cin>>t;
while(t--){
cin>>n;
string s;
cin>>s;
int a[26]={0};
for(int i=0;i<n;i++){
a[s[i]-'a']++;
}
cout<<alpha(a,n);
cout<<endl;
}
}
Problem Link: Bi_lindrome! Practice Coding Problem