class Solution {
List<List<Integer>> result = new ArrayList<>();
public List<List<Integer>> subsets(int[] nums) {
List<Integer> output = new ArrayList<>();
backTrace(nums,-1,output);
return result;
}
public void backTrace(int[] nums,int start,List<Integer> output){
result.add(new ArrayList<>(output));
for(int i = start+1;i < nums.length;i++){
output.add(nums[i]);
backTrace(nums,i,output);
output.remove(output.size() - 1);
}
}
}
leetcode78. 子集
最新推荐文章于 2024-11-10 21:54:30 发布