import java.util.*;
public class UniqueCombinations {
public static List<List<Integer>> combine(int[] nums) {
List<List<Integer>> result = new ArrayList<>();
backtrack(result, new ArrayList<>(), nums, 0);
return result;
}
private static void backtrack(List<List<Integer>> result, List<Integer> tempList,
int[] nums, int start) {
result.add(new ArrayList<>(tempList));
for (int i = start; i < nums.length; i++) {
____ // 填空
backtrack(result, tempList, nums, i + 1);
tempList.remove(tempList.size() - 1);
}
}
public static void main(String[] args) {
int[] nums = {1, 2, 3};
List<List<Integer>> combinations = combine(nums);
for (List<Integer> combination : combinations) {
System.out.println(combination);
}
}
}
填空内容是:
