


1. Each array element should belong to exactly one of the subsets.
2. Subsets need not always be contiguous.
For example, for the array : [1, 2, 3], some of the possible divisions are
a) {1,2} and {3}
b) {1,3} and {2}.
3. Subset-sum is the sum of all the elements in that subset.
Input: 'n' = 5, 'arr' = [3, 1, 5, 2, 8].
Ouput: 1
Explanation: We can partition the given array into {3, 1, 5} and {2, 8}.
This will give us the minimum possible absolute difference i.e. (10 - 9 = 1).
The first line of input contains integer 'n' denoting the size of the array.
The second line of the input contains 'n' space-separated integers denoting the elements of the array 'arr'.
Return the minimum possible absolute difference.
You do not need to print anything, it has already been taken care of. Just implement the given function.
We can think of this problem as the standard problem of dynamic programming, which is to check whether a subset exists with the given 'sum'.
Here we need to find if there is a way to partition a set into two subsets such that the difference between subset sums is minimum. We know that the best possible scenario is when the subset sums of both the subsets are equal, and thus we want both our subsets to have a sum as close to sum/2, where ‘sum’ is the total sum of elements in the array. So to achieve this, we need to check if there exists a subset with a sum up to half the total sum.