[leetcode] Subsets

来源:转载

public class Solution { List<List<Integer>> ret=new ArrayList<List<Integer>>(); public List<List<Integer>> subsets(int[] nums) { Arrays.sort(nums); List<Integer> list=new ArrayList<Integer>(); sub(list,nums,0,nums.length); return ret; } private void sub(List list,int[] nums,int k,int len){ if(k==len) ret.add(list); else{ sub(list,nums,k+1,len); List<Integer> tlist=new ArrayList<Integer>(); tlist.addAll(list); tlist.add(nums[k]); sub(tlist,nums,k+1,len); } }}



分享给朋友:
您可能感兴趣的文章:
随机阅读: