提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
一、力扣77. 组合
class Solution {
private List<List<Integer>> result = new ArrayList<>();
private LinkedList<Integer> path = new LinkedList<>();
public List<List<Integer>> combine(int n, int k) {
fun(n, k, 1);
return result;
}
public void fun(int n, int k, int startIndex){
if(path.size() == k){
result.add(new ArrayList(path));
return;
}
for(int i = startIndex; i<=(n-(k-path.size())+1); i++){
path.add(i);
fun(n, k, i+1);
path.removeLast();
}
}
}
882

被折叠的 条评论
为什么被折叠?



