Can anybody say what’s wrong with my code…
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;cin>>t;
while(t--){
string s;cin>>s;
int flag=0;
unordered_map<char,int>mp;
int single=0;
for(auto ch:s){
mp[ch]++;
}
for(auto ch:s){
if(mp[ch]==1) single++;
}
if(single>1) cout<<"NO"<<endl;
else{
string s1="";
for(auto ch:s){
if(mp[ch]>1) s1 =s1+ch;
}
int a =s1.size();
for(int i=0;i<a/2;i++){
if(s1[i]!=s1[a/2+i]){
cout<<"NO"<<endl;
flag=1;
break;
}
}
if(flag==0){
cout<<"YES"<<endl;
}
}
}
}