标签:
public class Solution { public ArrayList<ArrayList<Integer>> subsetsWithDup(int[] num) { ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>(); res.add(new ArrayList<Integer>()); if(num==null || num.length==0) return res; Arrays.sort(num); int start=0; for(int i=0; i<num.length;i++){ int len = res.size(); for(int j= start; j<len; j++){ ArrayList<Integer> tmp = new ArrayList<Integer>(res.get(j)); tmp.add(num[i]); res.add(tmp); } if(i<num.length-1 && num[i]==num[i+1]){ start = len; // let those processed data go for the dup one }else start =0; } return res; } }
ref http://blog.csdn.net/linhuanmars/article/details/24613193
标签:
原文地址:http://www.cnblogs.com/jiajiaxingxing/p/4431726.html