Subsets II

public class Solution {
public List<List<Integer>> subsetsWithDup(int[] nums) {
List<List<Integer>> result = new ArrayList<List<Integer>>();
if (nums == null || nums.length < 1) {
return result;
}
List<Integer> level = new ArrayList<Integer>();
Arrays.sort(nums);
dfs(result, level, 0, nums);
return result;
}
private void dfs(List<List<Integer>> result, List<Integer> level, int loc, int[] nums) {
for (int i = loc; i < nums.length; i++) {
if (i != loc&& nums[i] == nums[i - 1]) {
continue;
}
dfs(result, level, i + 1, nums);
level.remove(level.size() - 1);
}
}
}

LeetCode Subsets 和 LeetCode Subsets II

2014-04-09 22:02:48

[LeetCode 90] Subsets II

2015-03-28 00:32:07

LeetCode 90 Subsets II--In C++

2016-06-04 16:01:54

Subsets II -- LeetCode

2014-04-28 04:23:53

[C++]LeetCode: 64 Subsets II

2014-12-31 12:52:02

LeetCode90:Subsets II

2015-07-08 11:12:56

回溯法——subsets、subsets-ii数字数组的所有组合

2016-05-28 20:09:27

leetcode解题之 77. Combinations&78. Subsets&90. Subsets II java 版（求所有子集）

2017-04-08 19:36:52

90. Subsets II Leetcode Python

2015-01-15 06:03:55

leetCode 90.Subsets II（子集II） 解题思路和方法

2015-07-25 09:54:00