Problem of the day
Can you solve this using not more than O(S) extra space, where S is the sum of all elements of the given array?
The first line of input contains an integer 'T' representing the number of test cases or queries to be processed.
Then the test case follows.
The first line of each test case contains an integer 'N', denoting the size of the array.
The second line of each test case contains 'N' single space-separated integers representing the array elements.
For each test case, print “true” or “false” denoting whether we can partition into two equal subset-sum or not, in a separate line.
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= 'T' <= 10
1 <= 'N' <= 100
1 <= 'ARR'[i] <= 100
Time Limit: 1 sec
2
6
3 1 1 2 2 1
5
5 6 5 11 6
true
false
For the first test case, the array can be partitioned as ([2,1,1,1] and [3, 2]) or ([2,2,1], and [1,1,3]) with sum 5.
For the second test case, the array can’t be partitioned.
2
9
2 2 1 1 1 1 1 3 3
6
8 7 6 12 4 5
false
true