This commit is contained in:
youngyangyang04
2022-03-22 09:29:32 +08:00
parent f923b73deb
commit c408f7babc
62 changed files with 135 additions and 284 deletions

View File

@ -423,8 +423,8 @@ class Solution:
if len(path) == k:
res.append(path[:])
return
for i in range(startIndex,n - (k - len(path)) + 2): #优化的地方
path.append(i) #处理节点
for i in range(startIndex,n-(k-len(path))+2): #优化的地方
path.append(i) #处理节点
backtrack(n,k,i+1) #递归
path.pop() #回溯,撤销处理的节点
backtrack(n,k,1)