public List<List<Integer>> combine(int n, int k) {
List<List<Integer>> res = new ArrayList<>();
List<Integer> combination = new ArrayList<>();
getCombinations(1, n, k, combination, res);
public void getCombinations(int start, int n, int k, List<Integer> combination, List<List<Integer>> res) {
res.add(new ArrayList<>(combination));
for (int i = start; i <= n; i++) {
getCombinations(i + 1, n, k - 1, combination, res);
combination.remove(combination.size() - 1);