第77题. 组合
class Solution {
LinkedList<Integer> path =new LinkedList<>();
List<List<Integer>> result = new ArrayList<>();
public List<List<Integer>> combine(int n, int k) {
backTracing(n,k,0);
return result;
}
public void backTracing(int n,int size,int startIndex){
if(path.size()==size){
result.add(new ArrayList<>(path));
return;
}
for (int i = startIndex; i < n-(size-path.size())+1; i++) {
path.add(i+1);
backTracing(n,size,i+1);
path.removeLast();
}
}
}ava
标签:视频,int,接触,new,backTracing,result,回溯,path,size
From: https://www.cnblogs.com/Chain-Tian/p/17029232.html