GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Friday, 20 May 2022

[Solution] Xor Palindrome CodeChef Solution | CodeChef Problem Solution 2022

You are given a binary string A of length N.

You can perform the following type of operation on the string A:

  • Choose two different indices i and j (1≤i,j≤N);
  • Change Ai and Aj to Ai⊕Aj. Here ⊕ represents the bitwise XOR operation.

Solution Click Below:-  CLICK HERE

Find the minimum number of operations required to convert the given string into a palindrome.

Input Format

  • First line of the input contains T, the number of test cases. Then the test cases follow.







  • First line of each test case contains an integer N denoting the size of the string.
  • Second line of each test case contains a binary string A of length N containing 0s and 1s only.

Output Format

For each test case, print the minimum number of operations required to make the string a palindrome.

Constraints

  • 1≤T≤1000
  • 1≤N≤2⋅105
  • Sum of N over all test cases does not exceeds 2⋅105.

No comments:

Post a Comment