Help me in solving XORPAL problem

My issue

include
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while (t–) {
int n;
cin>>n;
string s;
cin>>s;
int ct1 = 0;
int ct2 = 0;
for (auto i:s) {
if (i == ‘0’) ct1++;
else ct2++;
}
if (n % 2 == 0) {

        if (ct2 % 2 == 0 && ct1 % 2 == 0) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    else {
        cout<<"YES"<<endl;
    }
}
return 0;

}
whats wrong with this code ? where its not working ?

My code

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while (t--) {
	    int n;
	    cin>>n;
	    string s;
	    cin>>s;
	     int ct1 = 0;
	        int ct2 = 0;
	        for (auto i:s) {
	            if (i == '0') ct1++;
	            else ct2++;
	        }
	    if (n % 2 == 0) {
	       
	        if (ct2 % 2 == 0 && ct1 % 2 == 0) cout<<"YES"<<endl;
	        else cout<<"NO"<<endl;
	    }
	    else {
	        cout<<"YES"<<endl;
	    }
	}
	return 0;
}

Problem Link: Xor Palindrome Practice Coding Problem

let testcase be
2
01
your ans will be NO
but correct ans is YES
as 0 ^1 =1 is same for all index