Skip to content

Commit

Permalink
Update is_balanced.py (#398)
Browse files Browse the repository at this point in the history
fixed a little bug
  • Loading branch information
jesili authored and keon committed Sep 4, 2018
1 parent 02b6e36 commit cdae90c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion algorithms/tree/is_balanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_depth(root):
return 0
left = get_depth(root.left)
right = get_depth(root.right)
if abs(left-right) > 1:
if abs(left-right) > 1 or left == -1 or right == -1:
return -1
return 1 + max(left, right)

Expand Down

0 comments on commit cdae90c

Please sign in to comment.