classSolution:defsubsets(self,nums: List[int]) -> List[List[int]]: res = []defdfs(pos,res,path):for i inrange(pos, len(nums)): path.append(nums[i])dfs(i +1, res, path) path.pop() res.append([i for i in path])dfs(0, res, [])return res
classSolution {privatevoidhelper(int[] nums,int start,List<Integer> path,List<List<Integer>> res) {res.add(newArrayList<>(path));for (int i = start; i <nums.length; i++) {path.add(nums[i]);helper(nums, i +1, path, res);path.remove(path.size() -1); } }publicList<List<Integer>> subsets(int[] nums) {List<List<Integer>> res =newArrayList<>();helper(nums,0,newArrayList<>(), res);return res; }}