## GUPTA MECHANICAL

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

# [Solution] Equal Distinct CodeChef Solution

## Problem

Let $F(S)$ denote the number of distinct elements in the array $S$. For example, $F([1, 2, 3, 2]) = 3, F([1, 2]) = 2.$

You are given an array $A$ containing $N$ integers. Find if it is possible to divide the elements of the array $A$ into two arrays $B$ and $C$ such that :

• Every element of the array $A$ belongs either to array $B$ or to array $C$.
• $F(B) = F(C)$.

### Input Format

• The first line of input will contain a single integer $T$, denoting the number of test cases.
• Each test case consists of two lines of input.
• The first line of each test case contains an integer $N$ — the length of the array $A$.
• The next line contains $N$ space-separated integer $A_1, A_2, \dots, A_N$, denoting the elements of the array $A$.

### Output Format

For each test case, print YES if it is possible to divide the elements of the array $A$ into two arrays $B, C$ satisfying all the conditions and NO otherwise.

Solution Click Below:-  👉
👇👇👇👇👇

You may print each character of the string in either uppercase or lowercase (for example, the strings yEsyesYes, and YES will all be treated as identical).

### Explanation:

Test case $1$: One possible division is $B = , C = $. Here $F(B) = F(C) = 1.$

Test case $2$: There is no way to distribute the elements of the array $A = [1, 2, 3]$ satisfying all the conditions.

Test case $3$: One possible division is $B = [3, 1], C = [1, 2]$. Here $F(B) = F(C) = 2.$