077.Combinations Posted on 2017-09-16 | In LeetCode Solution 1: accepted 28msDFS. 123456789101112131415161718192021222324252627class Solution { public List<List<Integer>> combine(int n, int k) { List<List<Integer>> result = new ArrayList<List<Integer>>(); List<Integer> list = new ArrayList<>(); if (n == 0) { return result; } comboHelper(result, list, n, k); return result; } private void comboHelper(List<List<Integer>> result, List<Integer> list, int n, int k) { if (k == 0) { result.add(new ArrayList<>(list)); } else { for (int i = n; i > 0; i--) { list.add(i); comboHelper(result, list, i - 1, k - 1); list.remove(list.size() - 1); } } }}