##Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.
For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.
class Solution:
# @param root, a tree node
# @return a boolean
# every node max height
def height(self, root):
if not root:
return 0
return max(self.height(root.left), self.height(root.right)) + 1
def isBalanced(self, root):
# root is empty, true
if not root:
return True
# every two children node height less than 1
if abs(self.height(root.left) - self.height(root.right)) <= 1:
return self.isBalanced(root.left) and self.isBalanced(root.right)
# not balance return False
else:
return False