Balanced Binary Tree
来源:互联网 发布:mysql高并发写入方案 编辑:程序博客网 时间:2024/05/26 07:27
public boolean isBalanced(TreeNode root) { // Start typing your Java solution below // DO NOT write main() function if(getHeight(root) == -1) return false; return true; } public int getHeight(TreeNode root) { if(root == null) return 0; int leftHeight = getHeight(root.left); if(leftHeight == -1) return -1; int rightHeight = getHeight(root.right); if(rightHeight == -1) return -1; if(Math.abs(leftHeight - rightHeight) > 1)return -1; return Math.max(leftHeight, rightHeight) + 1; }
- Balanced binary tree 扩展
- LeetCode: Balanced Binary Tree
- [LeetCode]Balanced Binary Tree
- LeetCode Balanced Binary Tree
- [Leetcode] Balanced Binary Tree
- LeetCode : Balanced Binary Tree
- LeetCode Balanced Binary Tree
- [LeetCode] Balanced Binary Tree
- Balanced Binary Tree
- Balanced Binary Tree
- 【leetcode】Balanced Binary Tree
- Balanced Binary Tree
- [LeetCode]Balanced Binary Tree
- Balanced Binary Tree
- Balanced Binary Tree
- [LeetCode] Balanced Binary Tree
- [Leetcode]Balanced Binary Tree
- [leetcode]Balanced Binary Tree
- Path Sum II
- oracle 体系结构(七)
- poj1365 Prime Land
- Minimum Depth of Binary Tree
- Android面试题
- Balanced Binary Tree
- 农民·编程·梦
- 微软亚院之编程判断俩个链表是否相交
- 如何画数据流图
- 新学期一水
- JQuery事件执行与DOM加载
- Convert Sorted Array to Binary Search Tree
- SEO公式小议
- 手机可以模拟NFC卡片吗?项目中如何解决不能模拟NFC Tag UID的问题