@@ -0,0 +1,1163 @@
+// Given a set of distinct integers, S, return all possible subsets.%0A%0A// Note:%0A// Elements in a subset must be in non-descending order.%0A// The solution set must not contain duplicate subsets.%0A// For example,%0A// If S = %5B1,2,3%5D, a solution is:%0A%0A// %5B%0A//   %5B3%5D,%0A//   %5B1%5D,%0A//   %5B2%5D,%0A//   %5B1,2,3%5D,%0A//   %5B1,3%5D,%0A//   %5B2,3%5D,%0A//   %5B1,2%5D,%0A//   %5B%5D%0A// %5D%0A%0Apublic class Solution %7B%0A    public List%3CList%3CInteger%3E%3E subsets(int%5B%5D S) %7B%0A        List%3CList%3CInteger%3E%3E result = new ArrayList%3CList%3CInteger%3E%3E();%0A        List%3CInteger%3E tempList = new ArrayList%3CInteger%3E();%0A%0A        if( S.length == 0) return result;%0A%0A        Arrays.sort(S);%0A%0A        for(int i = 0; i %3C= S.length; i++)%7B%0A        %09dfs(S, result, tempList, i, 0);%0A        %7D%0A%0A        return result;%0A    %7D%0A%0A    public void dfs(int%5B%5D S, List%3CList%3CInteger%3E%3E result, List%3CInteger%3E tempList, int len, int index)%7B%0A    %09if(tempList.size() == len)%7B%0A    %09%09result.add(new ArrayList%3CInteger%3E(tempList));%0A    %09%09return;%0A    %09%7D%0A%0A    %09for(int i = index; i %3C S.length; i++)%7B%0A    %09%09// go through all possible elements.%0A    %09%09tempList.add(S%5Bi%5D);%0A    %09%09dfs(S, result, tempList, len, i + 1);%0A    %09%09tempList.remove(tempList.size() - 1);%0A    %09%7D%0A    %7D%0A%7D

add subsets solution