###### LeetCode Balanced Binary Tree

Description:

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.

Solution:

import java.util.*;

public class Solution {
boolean flag = true;

public boolean isBalanced(TreeNode root) {
depth(root);
return flag;
}

int depth(TreeNode root) {
if (root == null)
return 0;
int left_dep = depth(root.left);
int right_dep = depth(root.right);
if (Math.abs(left_dep - right_dep) > 1)
flag = false;
return Math.max(left_dep, right_dep) + 1;
}
}

#### LeetCode(110)Balanced Binary Tree

2014-01-16 07:46:33

#### 【LeetCode】Balanced Binary Tree 解题报告

2014-10-12 20:15:29

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

2016-06-18 16:56:00

#### leetcode的题目：Balanced Binary Tree

2014年10月14日 145KB 下载

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

2015-08-11 07:34:02

#### Leetcode_110_Balanced Binary Tree

2014-12-28 21:35:16

#### leetcode 110 Balanced Binary Tree C++

2016-05-28 20:19:55

#### 【Leetcode】【python】Balanced Binary Tree

2017-08-03 04:10:38

#### LeetCode Convert Sorted List to Binary Search Tree 解题报告

2014-10-01 22:30:08

#### leetcode 110 Balanced Binary Tree

2015-07-19 20:43:02

## 不良信息举报

LeetCode Balanced Binary Tree