文章目录 力扣算法学习day20-378-子集题目代码实现 90-子集 II题目代码实现491-递增子序列,1.5h尝试失败,明日修改已复习 242-有效的字母异位词 力扣算法学习day20-3 78-子集 题目 代码实现 class Solution { List<List<Integer>> result = new ArrayList<>(); List<Integer> path = new ArrayList<>(); public List<List<Integer>> subsets(int[] nums) { recall(0,nums); return result; } public void recall(int i,int[] nums){ result.add(new ArrayList<>(path)); for(int j = i;j < nums.length;j++){ path.add(nums[j]); recall(j+1,nums); path.remove(path.size()-1); } } } 90-子集 II 题目 代码实现 class Solution { List<List<Integer>> result = new ArrayList<>(); List<Integer> path = new ArrayList<>(); public List<List<Integer>> subsetsWithDup(int[] nums) { Arrays.sort(nums); recall(0,nums); return result; } public void recall(int i,int[] nums){ result.add(new ArrayList<>(path)); for(int j = i;j < nums.length;j++){ if(j > i && nums[j] == nums[j - 1]){ continue; } path.add(nums[j]); recall(j+1,nums); path.remove(path.size()-1); } } } 491-递增子序列,1.5h尝试失败,明日修改 已复习 242-有效的字母异位词