题目
类型:回溯
解题思路
代码
class Solution {public List<List<Integer>> subsets(int[] nums) {List<List<Integer>> res = new ArrayList<>();backtrack(0, nums, res, new ArrayList<Integer>());return res;}private void backtrack(int i, int[] nums, List<List<Integer>> res, ArrayList<Integer> tmp) {res.add(new ArrayList<>(tmp));for (int j = i; j < nums.length; j++) {tmp.add(nums[j]);backtrack(j + 1, nums, res, tmp);tmp.remove(tmp.size() - 1);}}}
