Given a collection of integers that might contain duplicates, S, return all possible subsets.
Note:
For example,
If S = [1,2,2], a solution is:
[ [2], [1], [1,2,2], [2,2], [1,2], [] ]遞歸+增量構造法
public class Solution {
List> res = new ArrayList>();
List list = new ArrayList();
public List> subsetsWithDup(int[] num) {
Arrays.sort(num);
help(num,0);
return res;
}
private void help(int[]num,int start){
if(!res.contains(list)){
List lin = new ArrayList(list);
res.add(lin);
}
for(int i=start;i