Balanced Binary Tree 原

LuXing

``````/**
* Definition for binary tree
* public class TreeNode {
*     int val;
*     TreeNode left;
*     TreeNode right;
*     TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public boolean isBalanced(TreeNode root) {
if(root == null){
return true;
}
if( root.right == null && root.left != null && (root.left.left != null || root.left.right != null) ){
return false;
}

if(root.left == null && root.right != null && (root.right.right != null || root.right.left != null))
{
return false;
}
return isBalanced(root.left) && isBalanced(root.right);
}
}``````

 Input: {1,2,2,3,3,#,#,4,4} Output: true Expected: false

LuXing

leetcode -- Balanced Binary Tree

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 t......

leiline
2018/01/12
0
0
leetCode 110. Balanced Binary Tree 平衡二叉树

110. 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......

wbf961127
2017/11/13
0
0
110. Balanced Binary Tree - LeetCode

Question 110. Balanced Binary Tree Solution 题目大意：判断一个二叉树是不是平衡二叉树 思路：定义个boolean来记录每个子节点是否平衡 Java实现： Ref https://www.youtube.com/watch?v=...

yysue
2018/08/15
0
0
Leetcode 108. Convert Sorted Array to Binary Search Tree

xgnming
2018/08/28
0
0
Leetcode 110. Balanced Binary Tree

SnailTyan
2018/09/19
0
0

ehcache

17分钟前
0
0
Android服务2 BindService

MainActivity { class MyService extends Service { public void onCreate() {} public IBinder onBind(Intent intent) { //return new Binder(); retutn new MyBinder(); } public boolean ......

Coding缘
56分钟前
0
0

Java填坑路

1
0

1
0

2
0