Skip to content

Commit 50da5ee

Browse files
committed
leetcode/grind:50 subtree of another tree-brute force recursive
1 parent a04675d commit 50da5ee

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

leetcode/grind75/subtree_of_another_tree.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
def is_subtree(root, sub_root)
2424
return true if sub_root.nil?
2525
return false if root.nil?
26-
is_found = false
27-
if root.val == sub_root.val
28-
return true if is_same_tree(root, sub_root)
29-
end
26+
return true if is_same_tree(root, sub_root)
3027
is_subtree(root.left, sub_root) || is_subtree(root.right, sub_root)
3128
end
3229

0 commit comments

Comments
 (0)