
Input: 'ARR' = [1, 2, 4, 4, 1, 2]
Output: true
We can split the above array like this: [1, 1], [4, 4], [2, 2]
In the three subsets, each of size two. And every subset contains the same elements.
The first line of input contains an integer 'T', denoting the number of test cases.
The first line of each test case contains a single integer 'N' size of the input array ‘ARR’. The second line contains 'N' integers the array elements.
For each test case, print "true" if it is possible to split the array else print "false".
Output for each test case will be printed in a separate line.
You don't need to print anything. It has already been taken care of. Just implement the given function.
1 <= ‘T’ <= 10
1 <= 'N' <= 10^5
-10^9 <= 'ARR[i]'<= 10^9
Time Limit : 1 sec
We can easily solve this problem by counting the frequency of every number of the array using a hashmap, and then we can form the groups according to the gcd of frequency count.
If the gcd is one then it is not possible to split the array, else it is possible.
Algorithm: