My issue
After counting the number of different pairs of bits in the string I don’t understand how it goes that answer is (count+1)/2.
My code
#include<iostream>
#include<string>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string s;
cin>>s;
int count=0;
for(int i=1;i<=n/2;i++)
{
if(s[i]!=s[n-i+1])
{
count++;
}
}
cout<<(count+1)/2<<endl;
}
}
Problem Link: Xor Palindrome Practice Coding Problem