mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-05 03:30:30 +08:00
Update preorder_traversal_iii.
This commit is contained in:
@@ -39,6 +39,6 @@ if __name__ == "__main__":
|
||||
res = list[list[TreeNode]]()
|
||||
pre_order(root)
|
||||
|
||||
print("\n输出所有根节点到节点 7 的路径,路径中不包含值为 3 的节点,仅包含一个值为 7 的节点")
|
||||
print("\n输出所有根节点到节点 7 的路径,路径中不包含值为 3 的节点")
|
||||
for path in res:
|
||||
print([node.val for node in path])
|
||||
|
||||
@@ -43,7 +43,6 @@ def backtrack(
|
||||
if is_solution(state):
|
||||
# 记录解
|
||||
record_solution(state, res)
|
||||
return
|
||||
# 遍历所有选择
|
||||
for choice in choices:
|
||||
# 剪枝:检查选择是否合法
|
||||
|
||||
Reference in New Issue
Block a user