https://oj.leetcode.com/problems/subsets/
http://blog.csdn.net/linhuanmars/article/details/24286377
public class Solution { public List<List<Integer>> subsets(int[] S) { Arrays.sort(S); List<List<Integer>> results = new ArrayList<>(); help(S, 0, new ArrayList<Integer>(), results); return results; } private void help(int[] S, int start, List<Integer> items, List<List<Integer>> results) { if (items.size() <= S.length) { results.add(new ArrayList<Integer>(items)); } if (items.size() == S.length) return; for (int i = start ; i < S.length ; i ++) { items.add(S[i]); help(S, i + 1, items, results); items.remove(items.size() - 1); } } }
原文地址:http://7371901.blog.51cto.com/7361901/1599001