Fix the codes of backtracking.

pull/462/head
krahets 2 years ago
parent 3d4fb3dbd7
commit 1600ed6dee

@ -15,15 +15,12 @@ public class preorder_find_nodes {
if (root == null) {
return;
}
// 尝试
if (root.val == 7) {
// 记录解
res.add(root);
}
preOrder(root.left);
preOrder(root.right);
// 回退
return;
}
public static void main(String[] args) {

@ -24,7 +24,6 @@ def pre_order(root: TreeNode) -> None:
pre_order(root.right)
# 回退
path.pop()
return
"""Driver Code"""

@ -23,7 +23,6 @@ def pre_order(root: TreeNode) -> None:
pre_order(root.right)
# 回退
path.pop()
return
"""Driver Code"""

Loading…
Cancel
Save