# Palindrome Flipping Codechef Solution

### We Are Discuss About CODECHEF SOLUTION

Palindrome Flipping Codechef Solution

## Palindrome Flipping Codechef Solution

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW

## Problem

Chef has a binary string S of length N.

In one operation, Chef can:

• Select two indices i and j (1 \le i, j \le N) and flip S_i and S_j. (i.e. change 0 to 1 and 1 to 0)

For example, if S = 10010 and chef applys operation on i = 1 and j = 3 then: \underline{1}0\underline{0}10 \rightarrow 00110.

Find if it is possible to convert S to a palindrome by applying the above operation any (possibly zero) number of times.

Note: A string is called a palindrome if it reads the same backwards and forwards, for e.g. 10001 and 0110 are palindromic strings.

### Input Format

• The first line contains a single integer T — the number of test cases. Then the test cases follow.
• The first line of each test case contains an integer N — the length of the binary string S.
• The second line of each test case contains a binary string S of length N containing 0s and 1s only.

### Output Format

For each test case, output YES if it is possible to convert S to a palindrome. Otherwise, output NO.

You can print each character of the string in uppercase or lowercase. For example, the strings YESyesYes, and yEs are all considered the same.

### Constraints

• 1 \leq T \leq 10^5
• 1 \leq N \leq 10^5
• S contains 0 and 1 only.
• Sum of N over all test cases does not exceed 2 \cdot 10^5.

Input

Output

3
6
101011
2
01
7
1110000
YES
NO
YES

### Explanation:

Test case 1: We can perform the following operation:

• Select i = 3 and j = 5. Then 10\underline{1}0\underline{1}1 \rightarrow 100001, which is a palindrome.

Test case 2: It can be proven that we can not make S a palindrome using the given operation.

Test case 3: We can perform the following operations:

• Select i = 4 and j = 5. Then 111\underline{0}\underline{0}00 \rightarrow 1111100
• Select i = 6 and j = 7. Then 11111\underline{0}\underline{0} \rightarrow 1111111, which is a palindrome.
Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW

## Palindrome Flipping Codechef Solution

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here JOIN NOW

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW