# LeetCode110 Blanced Binary Tree Java 题解

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.

if(right==-1) return -1保证只要出现一个高度差为-1的最终返回结果必然为-1，也就是说最终可以根据返回值是不是-1判断是不是平衡二叉树

public static boolean isBalanced(TreeNode root) {
if(treeHight(root)==-1)
return false;
else
return true;

}

public static int treeHight(TreeNode root)
{
if(root==null)
return 0;
else {
int left=treeHight(root.left);
int right=treeHight(root.right);
if(left==-1) return -1;
if(right==-1) return -1;
if(Math.abs(left-right)>1)
return -1;
else {
return 1+Math.max(treeHight(root.left), treeHight(root.right));
}
}
}

#### LeetCode 110. Balanced Binary Tree 递归求解

2016-02-23 16:28:36

#### 【LeetCode-面试算法经典-Java实现】【110-Balanced Binary Tree（平衡二叉树）】

2015-08-11 07:34:02

#### LeetCode(110)Balanced Binary Tree

2014-01-16 07:46:33

#### 【leetCode】 Balanced Binary Tree python版实现

2016-06-18 16:56:00

#### zoj 3965 Binary Tree Restoring（* dfs）

2017-04-25 21:47:59

#### leetcode110题 题解 翻译 C语言版 Python版

2016-04-14 21:01:46

#### LeetCode110 Balanced Binary Tree

2017-04-29 18:55:42

#### LeetCode110 - Balanced Binary Tree

2015-03-27 16:41:29

#### 【LeetCode】Binary Tree Maximum Path Sum 解题报告

2015-01-22 16:15:05

#### PAT甲级1135----红黑树题解

2017-09-25 22:36:42