mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 11:34:46 +08:00
修复 0077.组合 python未剪枝和剪枝代码一样的问题
This commit is contained in:
@ -405,7 +405,7 @@ class Solution:
|
|||||||
if len(path) == k:
|
if len(path) == k:
|
||||||
res.append(path[:])
|
res.append(path[:])
|
||||||
return
|
return
|
||||||
for i in range(StartIndex, n-(k-len(path)) + 2):
|
for i in range(StartIndex, n + 1):
|
||||||
path.append(i)
|
path.append(i)
|
||||||
backtrack(n, k, i+1)
|
backtrack(n, k, i+1)
|
||||||
path.pop()
|
path.pop()
|
||||||
@ -414,7 +414,7 @@ class Solution:
|
|||||||
```
|
```
|
||||||
|
|
||||||
剪枝:
|
剪枝:
|
||||||
```python3
|
```python
|
||||||
class Solution:
|
class Solution:
|
||||||
def combine(self, n: int, k: int) -> List[List[int]]:
|
def combine(self, n: int, k: int) -> List[List[int]]:
|
||||||
res=[] #存放符合条件结果的集合
|
res=[] #存放符合条件结果的集合
|
||||||
|
Reference in New Issue
Block a user