function height(root) {
if (!root) return 0
return 1 + Math.max(height(root.left), height(root.right))
}
function isBalanced(root) {
if (!root) return true
return Math.abs(height(root.left) - height(root.right)) <= 1 &&
isBalanced(root.left) &&
isBalanced(root.right)
}