 Timer is Running

Minimum sum partition
##### Submissions: 26765   Accuracy: 48.41%   Difficulty: Hard   Marks: 8

Given an array, the task is to divide it into two sets S1 and S2 such that the absolute difference between their sums is minimum.

Input:
The first line contains an integer 'T' denoting the total number of test cases. In each test cases, the first line contains an integer 'N' denoting the size of array. The second line contains N space-separated integers A1, A2, ..., AN denoting the elements of the array.

Output:
In each seperate line print minimum absolute difference.

Constraints:
1<=T<=200
1<=N<=50
1<=A[i]<=200

Example:
Input:
2
4
1 6 5 11
4
36 7 46 40

Output :
1
23

Explaination :
Testcase 1:
Subset1 = {1, 5, 6} ; sum of Subset1 = 12
Subset2 = {11} ;       sum of Subset2 = 11

Testcase 2:
Subset1 = {7, 46} ;   sum = 53
Subset2 = {36, 40} ; sum = 76

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

Author: abhiraj26

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.