Update bst_is_balanced.py

This commit is contained in:
bt3gl 2023-08-08 15:03:55 -07:00 committed by GitHub
parent f7dc8af9c4
commit 39922339a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,7 @@
def height(root):
if not root:
if root is None:
return -1
return 1 + max(height(root.left), height(root.right))
@ -13,7 +13,7 @@ def height(root):
def is_balanced(root):
if not root:
if root is None:
return True
return abs(height(root.left) - height(root.right)) < 2 and \