简单回溯即可
class Solution {
List<List<Integer>> l = new ArrayList<>();
public List<List<Integer>> subsets(int[] nums) {
find(nums, 0, new ArrayList<Integer>());
return l;
}
void find(int[] nums, int index, List<Integer> t){
if(index == nums.length){
l.add(new ArrayList<Integer>(t));
return;
}
t.add(nums[index]);
find(nums, index + 1, t);
t.remove(t.size() - 1);
find(nums, index + 1, t);
}
}