publicclasslc78{ List<List<Integer>> res; public List<List<Integer>> subsets(int[] nums) { res = new ArrayList<>(); List<Integer> path = new ArrayList<>();
int len = nums.length; process(nums, 0, len, path); return res; }
privatevoidprocess(int[] nums, int i, int len, List<Integer> path){ res.add(new ArrayList<>(path)); for (int j = i; j < len; j++) { path.add(nums[j]); process(nums, j+1, len, path); path.remove(path.size()-1); } } }