From 1600ed6dee49ddd6dbb80675c87e99985c31e7ca Mon Sep 17 00:00:00 2001 From: krahets Date: Sun, 16 Apr 2023 05:14:15 +0800 Subject: [PATCH] Fix the codes of backtracking. --- codes/java/chapter_backtracking/preorder_find_nodes.java | 3 --- .../chapter_backtracking/preorder_find_constrained_paths.py | 1 - codes/python/chapter_backtracking/preorder_find_paths.py | 1 - 3 files changed, 5 deletions(-) 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"""