Merge pull request #982 from tlylt/fix-77-python

fix Qn0077 Python indent
This commit is contained in:
程序员Carl
2022-01-06 20:51:12 +08:00
committed by GitHub
3 changed files with 6 additions and 7 deletions

View File

@ -422,13 +422,13 @@ class Solution:
def backtrack(n,k,startIndex): def backtrack(n,k,startIndex):
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 - (k - len(path)) + 2): #优化的地方
path.append(i) #处理节点 path.append(i) #处理节点
backtrack(n,k,i+1) #递归 backtrack(n,k,i+1) #递归
path.pop() #回溯,撤销处理的节点 path.pop() #回溯,撤销处理的节点
backtrack(n,k,1) backtrack(n,k,1)
return res return res
``` ```

View File

@ -182,13 +182,13 @@ class Solution:
def backtrack(n,k,startIndex): def backtrack(n,k,startIndex):
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-(k-len(path))+2): #优化的地方
path.append(i) #处理节点 path.append(i) #处理节点
backtrack(n,k,i+1) #递归 backtrack(n,k,i+1) #递归
path.pop() #回溯,撤销处理的节点 path.pop() #回溯,撤销处理的节点
backtrack(n,k,1) backtrack(n,k,1)
return res return res
``` ```
Go Go
```Go ```Go

View File

@ -323,7 +323,6 @@ class Solution:
self.backtracking(k, n, i + 1) self.backtracking(k, n, i + 1)
self.path.pop() self.path.pop()
self.sum_now -= i self.sum_now -= i
return
``` ```
## Go ## Go