package leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * https://leetcode.com/problems/combination-sum-iii/
 */
public class Problem216 {
    public List<List<Integer>> combinationSum3(int k, int n) {
        List<List<Integer>> result = new ArrayList<>();
        // TODO
        return result;
    }

    public static void main(String[] args) {
        Problem216 prob = new Problem216();
    }
}

@@ -283,134 +283,880 @@
     
-// TODO%0A        return result;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem216 prob = new Problem216();
+List%3CInteger%3E numbers = new ArrayList%3C%3E();%0A        for (int i = 1; i %3C= 9; i++) %7B%0A            numbers.add(i);%0A        %7D%0A        List%3CInteger%3E accu = new ArrayList%3C%3E();%0A        combination(numbers, k, n, 0, 0, accu, result);%0A        return result;%0A    %7D%0A%0A    private void combination(List%3CInteger%3E numbers, int k, int n, int idx, int sum,%0A                             List%3CInteger%3E accu, List%3CList%3CInteger%3E%3E result) %7B%0A        if (sum == n) %7B%0A            if (k == 0) %7B%0A                result.add(accu);%0A            %7D%0A            return;%0A        %7D%0A        if (numbers.size() == 0) %7B%0A            return;%0A        %7D%0A        for (int i = idx; i %3C numbers.size(); i++) %7B%0A            int val = numbers.get(i);%0A            List%3CInteger%3E newAccu = new ArrayList%3C%3E(accu);%0A            newAccu.add(val);%0A            combination(numbers, k-1, n, i+1, sum+val, newAccu, result);%0A        %7D
 %0A   

Solve problem 216