Split array into two equal length subsets such that all repetitions of a number lies in a single subset
Given an array arr[] consisting of N integers, the task is to check if it is possible to split the integers into two equal length subsets such that all repetitions of any array element belongs to the same subset. If found to be true, print “Yes”. Otherwise, print “No”. Examples: Input: arr[] = {2, 1, 2, 3} Output: Yes Explanation: One possible way of dividing the array is {1, 3} and {2, 2} Input: arr[] = {1, 1, 1, 1} Output: No Naive Approach: The simplest approach to solve the problem is to try all possible combinations of splitting the array into two equal subsets. For each combination, check whether every repetition belongs to only one of the two sets or not. If found to be true, then print “Yes”. Otherwise, print “No”. Time Complexity: O(2N), where N is the size of the given integer. Auxiliary Space: O(N) Efficient Approach: The above approach can be optimized by storing the frequency of all elements of the given array in an array freq[]. For elements to be divided into two equal s...