https://oj.leetcode.com/problems/subsets-ii/
http://blog.csdn.net/linhuanmars/article/details/24613193
public class Solution {
public List<List<Integer>> subsetsWithDup(int[] num) {
Arrays.sort(num);
Set<List<Integer>> results = new HashSet<>();
help(num, 0, new ArrayList<Integer>(), results);
return new ArrayList<List<Integer>>(results);
}
// Don‘t know how to handle duplicate cases :(
// Using set
private void help(int[] n, int start, List<Integer> items, Set<List<Integer>> results)
{
results.add(new ArrayList<Integer>(items));
for (int i = start ; i < n.length ; i ++)
{
items.add(n[i]);
help(n, i + 1, items, results);
items.remove(items.size() - 1);
}
}
}原文:http://7371901.blog.51cto.com/7361901/1599096