Skip to content

Commit 57420fc

Browse files
author
Joseph Luce
authored
Update 110_balanced_binary_tree.md
1 parent 431bdd3 commit 57420fc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

leetcode/easy/110_balanced_binary_tree.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ class Solution:
2020
if root is None:
2121
return 0
2222
left = balance_helper(root.left)
23+
if left == -1:
24+
return -1
2325
right = balance_helper(root.right)
24-
if left == -1 or right == -1:
26+
if right == -1:
2527
return -1
2628
return max(left, right)+1 if abs(left-right) <= 1 else -1
2729

0 commit comments

Comments
 (0)