public List<List<Integer>> combine(int n, int k) { List<List<Integer>> result = newArrayList<>(); List<Integer> list = newArrayList<>(); combineDFS(1, n, k, list, result); return result; } /** * * @param start 当前开始节点 * @param n n * @param k k * @param list 每个list * @param result 最后的结果 */ privatevoidcombineDFS(int start, int n, int k, List<Integer> list, List<List<Integer>> result) { if (list.size() == k) { List<Integer> resultOne = newArrayList<>(k); resultOne.addAll(list); result.add(resultOne); return; }