File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -405,7 +405,7 @@ class Solution:
405
405
if len (path) == k:
406
406
res.append(path[:])
407
407
return
408
- for i in range (StartIndex, n- (k - len (path)) + 2 ):
408
+ for i in range (StartIndex, n + 1 ):
409
409
path.append(i)
410
410
backtrack(n, k, i+ 1 )
411
411
path.pop()
@@ -414,7 +414,7 @@ class Solution:
414
414
```
415
415
416
416
剪枝:
417
- ``` python3
417
+ ``` python
418
418
class Solution :
419
419
def combine (self , n : int , k : int ) -> List[List[int ]]:
420
420
res= [] # 存放符合条件结果的集合
@@ -423,7 +423,7 @@ class Solution:
423
423
if len (path) == k:
424
424
res.append(path[:])
425
425
return
426
- for i in range (startIndex,n- (k - len (path))+ 2 ): # 优化的地方
426
+ for i in range (startIndex,n - (k - len (path)) + 2 ): # 优化的地方
427
427
path.append(i) # 处理节点
428
428
backtrack(n,k,i+ 1 ) # 递归
429
429
path.pop() # 回溯,撤销处理的节点
You can’t perform that action at this time.
0 commit comments