Timer is Running

Subset Sum Problem
##### Submissions: 106966   Accuracy: 25.26%   Difficulty: Medium   Marks: 4

Given a set of numbers, check whether it can be partitioned into two subsets such that the sum of elements in both subsets is same or not.

Input:
The first line contains an integer 'T' denoting the total number of test cases. Each test case constitutes of two lines. First line contains 'N', representing the number of elements in the set and the second line contains the elements of the set.

Output:
Print YES if the given set can be partioned into two subsets such that the sum of elements in both subsets is equal, else print NO.

Constraints:
1 <= T <= 100
1 <= N <= 100
0 <= arr[i] <= 1000

Example:
Input:

2
4
1 5 11 5
3
1 3 5

Output:
YES
NO

Explanation:
Testcase 1:
There exists two subsets such that {1, 5, 5} and {11}.

#### ** For More Input/Output Examples Use 'Expected Output' option **

Author: atharv

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.