@@ -0,0 +1,1476 @@
+/** Given a set of distinct integers, nums, return all possible subsets.%0A *%0A * %09Note:%0A *%09Elements in a subset must be in non-descending order.%0A *%09The solution set must not contain duplicate subsets.%0A *%09For example,%0A *%09If nums = %5B1,2,3%5D, a solution is:%0A *%0A *%09%5B%0A *%09%09%5B3%5D,%0A * %09%09%5B1%5D,%0A * %09%09%5B2%5D,%0A * %09%09%5B1,2,3%5D,%0A * %09%09%5B1,3%5D,%0A * %09%09%5B2,3%5D,%0A * %09%09%5B1,2%5D,%0A * %09%09%5B%5D%0A *%09%5D%0A *%0A *%09Author: matao%0A * %09%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92%0A */%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0Apublic class Subsets %7B%0A    public static List%3CList%3CInteger%3E%3E subsets(int%5B%5D nums) %7B%0A        List%3CList%3CInteger%3E%3E result = new ArrayList%3CList%3CInteger%3E%3E();%0A        if(nums == null %7C%7C nums.length == 0)%0A            return result;%0A        Arrays.sort(nums);%0A        List%3CInteger%3E list = new ArrayList%3CInteger%3E();%0A        subsetsHelper(result, list, nums, 0);%0A        return result;%0A    %7D%0A    %0A    public static void subsetsHelper(List%3CList%3CInteger%3E%3E result, List%3CInteger%3E list, int%5B%5D nums, int pos) %7B%0A        result.add(new ArrayList%3CInteger%3E(list));%0A        for(int i = pos; i %3C nums.length; i++) %7B%0A            list.add(nums%5Bi%5D);%0A            subsetsHelper(result, list, nums, i+1);%0A            list.remove(list.size()-1);%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A%09%09int%5B%5D nums = %7B1, 2%7D;%0A%09%09List%3CList%3CInteger%3E%3E lists = subsets(nums);%0A%09%09for (List%3CInteger%3E arrayList : lists) %7B%0A%09%09%09for (Integer integer : arrayList) %7B%0A%09%09%09%09System.out.print(integer.toString() + %22 %22);%0A%09%09%09%7D%0A%09%09%09System.out.println();%0A%09%09%7D%0A%09%7D%0A%7D

add subsets solution