package leetcode;

/**
 * https://leetcode.com/problems/sum-of-all-subset-xor-totals/
 */
public class Problem1863 {
    public int subsetXORSum(int[] nums) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1863 prob = new Problem1863();
        System.out.println(prob.subsetXORSum(new int[]{1,3})); // 6
        System.out.println(prob.subsetXORSum(new int[]{5,1,6})); // 28
        System.out.println(prob.subsetXORSum(new int[]{3,4,5,6,7,8})); // 480
    }
}

@@ -12,16 +12,68 @@
 tcode;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 /**%0A * h
@@ -216,15 +216,89 @@
     
-// TODO
+IntRef ref = new IntRef();%0A        subSetXORSum(nums, 0, new ArrayList%3C%3E(), ref);
 %0A   
@@ -309,17 +309,23 @@
  return 
-0
+ref.val
 ;%0A    %7D%0A
@@ -334,91 +334,232 @@
    p
-ublic static void main(String%5B%5D args) %7B%0A        Problem1863 prob = new Problem1863(
+rivate static class IntRef %7B%0A        private int val;%0A    %7D%0A%0A    private static void subSetXORSum(int%5B%5D nums, int index, List%3CInteger%3E subset, IntRef ref) %7B%0A        if (!subset.isEmpty()) %7B%0A            int xor = subset.get(0
 );%0A 
@@ -569,104 +569,245 @@
     
-System.out.println(prob.subsetXORSum(new int%5B%5D%7B1,3%7D)); // 6%0A        System.out.println(prob.subs
+    for (int i = 1; i %3C subset.size(); i++) %7B%0A                xor %5E= subset.get(i);%0A            %7D%0A            ref.val += xor;%0A        %7D%0A        for (int i = index; i %3C nums.length; i++) %7B%0A            subset.add(nums%5Bi%5D);%0A            subS
 etXO
@@ -816,110 +816,89 @@
 um(n
-ew int%5B%5D%7B5,1,6%7D)); // 28%0A        System.out.println(prob.subsetXORSum(new int%5B%5D%7B3,4,5,6,7,8%7D)); // 480
+ums, i + 1, subset, ref);%0A            subset.remove(subset.size() - 1);%0A        %7D
 %0A   

Solve problem 1863