判断一颗二叉树是否为平衡二叉树
public boolean isBalanced(TreeNode root){
if(root==null) return true;
else{
int m = depth(root.left);
int n = depth(root.right);
if(m-n>1 || n-m>1) return false;
else return isBalanced(root.left) && isBalanced(root.right);
}
}
public int Depth(TreeNode root){
if(root==null) return 0;
else{
int m = Depth(root.left);
int n = Depth(root.right);
return (m>n?m:n)+1;
}
}