2
public int minimumDifference(int[] nums) {9
TreeSet<Integer>[] sets = new TreeSet[n / 2 + 1];10
for (int i = 0; i < (1 << (n / 2)); ++i) {13
for (int j = 0; j < n / 2; ++j) {14
if ((i & (1 << j)) != 0) {19
if (sets[m] == null) sets[m] = new TreeSet<Integer>();23
int res = Integer.MAX_VALUE / 3;24
for (int i = 0; i < (1 << (n / 2)); ++i) {27
for (int j = 0; j < n / 2; ++j) {28
if ((i & (1 << j)) != 0) {29
curSum += nums[n / 2 + j];33
int target = (sum - 2 * curSum) / 2;35
Integer left = sets[n / 2 - m].floor(target), right = sets[n / 2 - m].ceiling(target);37
res = Math.min(res, Math.abs(sum - 2 * (curSum + left.intValue())));41
res = Math.min(res, Math.abs(sum - 2 * (curSum + right.intValue())));44
if (res == 0) return 0;50
// Time Complexity: O(2^(n/2) * n/2 * n/2)