diff --git a/codes/java/chapter_backtracking/preorder_find_nodes.java b/codes/java/chapter_backtracking/preorder_find_nodes.java index 605c0201e..3208b031f 100644 --- a/codes/java/chapter_backtracking/preorder_find_nodes.java +++ b/codes/java/chapter_backtracking/preorder_find_nodes.java @@ -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) { diff --git a/codes/python/chapter_backtracking/preorder_find_constrained_paths.py b/codes/python/chapter_backtracking/preorder_find_constrained_paths.py index 8ea42738c..e0670e2e7 100644 --- a/codes/python/chapter_backtracking/preorder_find_constrained_paths.py +++ b/codes/python/chapter_backtracking/preorder_find_constrained_paths.py @@ -24,7 +24,6 @@ def pre_order(root: TreeNode) -> None: pre_order(root.right) # 回退 path.pop() - return """Driver Code""" diff --git a/codes/python/chapter_backtracking/preorder_find_paths.py b/codes/python/chapter_backtracking/preorder_find_paths.py index 781d96d8a..59ca81663 100644 --- a/codes/python/chapter_backtracking/preorder_find_paths.py +++ b/codes/python/chapter_backtracking/preorder_find_paths.py @@ -23,7 +23,6 @@ def pre_order(root: TreeNode) -> None: pre_order(root.right) # 回退 path.pop() - return """Driver Code"""