Partition Equal Subset Sum Problem
Given an array ARR
consisting of 'N' positive integers, determine if it is possible to partition the array into two subsets such that the sum of the elements in both subsets is equal.
Input:
The first line of input provides an integer 'T' indicating the number of test cases.
For each test case:
- The first line contains a single integer 'N', the size of the array.
- The second line contains 'N' space-separated positive integers representing the elements of the array.
Output:
Output 'true' for each test case if the array can be partitioned into subsets with equal sum, otherwise output 'false'. Each result should be on a new line.
Example:
Input:
1
6
2 3 3 3 4 5
Output:
true
Explanation:
The array can be partitioned into two subsets, [2, 3, 5] and [3, 3, 4], both having a sum of 10.
Constraints:
1 <= T <= 10
1 <= N <= 100
1 <= ARR[i] <= 100
Note:
You do not need to print anything, as the implementation handles only computing the results.
Be the first one to answer
Add answer anonymously...
Top Ola Cabs SDE-2 interview questions & answers
Popular interview questions of SDE-2
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app