public List<List<Integer>> subsets(int[] S) {
			if (S == null || S.length == 0) {
				return new ArrayList<List<Integer>>();
			}
			// non-descending
			Arrays.sort(S);
			List<List<Integer>> ret = new LinkedList<List<Integer>>();
			ret.add(new ArrayList<Integer>());
			for (int i = 1; i <= S.length; ++i) {
				int[] counts = new int[S.length];
				for (int j = 0; j < i; ++j) {
					counts[j] = 1;
				}
				do {
					List<Integer> set = new ArrayList<Integer>(i);
					for (int j = 0; j < S.length; ++j) {
						if (counts[j] == 1) {
							set.add(S[j]);
						}
					}
					ret.add(set);
				} while (compute(counts));
			}
			return ret;

		}