Leetcode 110. Balanced Binary Tree
来源:互联网 发布:mac照片导入iphone8 编辑:程序博客网 时间:2024/06/02 04:52
public class Solution { public boolean isBalanced(TreeNode root) { // do an inorder traverse if (root == null) return true; if (Math.abs(getHeight(root.left) - getHeight(root.right)) > 1) return false; if (!isBalanced(root.left) || !isBalanced(root.right)) return false; return true; } // determine the height of a given tree t public static int getHeight(TreeNode t) { if (t == null) return 0; return 1 + Math.max(getHeight(t.left), getHeight(t.right)); }}
0 0
- LeetCode 110. Balanced Binary Tree
- [LeetCode]110.Balanced Binary Tree
- 【LeetCode】110.Balanced Binary Tree
- [Leetcode] 110. Balanced Binary Tree
- LeetCode --- 110. Balanced Binary Tree
- [leetcode] 110.Balanced Binary Tree
- [leetcode]110. Balanced Binary Tree
- LeetCode:110. Balanced Binary Tree
- 110. Balanced Binary Tree LeetCode
- [LeetCode]110. Balanced Binary Tree
- Leetcode 110. Balanced Binary Tree
- LeetCode 110. Balanced Binary Tree
- LeetCode *** 110. Balanced Binary Tree
- leetcode 110. Balanced Binary Tree
- LeetCode 110. Balanced Binary Tree
- LeetCode 110. Balanced Binary Tree
- #leetcode#110. Balanced Binary Tree
- leetcode-110. Balanced Binary Tree
- LeetCode 261. Graph Valid Tree
- 在c# winfrom中加载com组件
- 基础练习 字母图形
- centos7 关闭firewall安装iptables并配置,关闭SELINUX
- Java 字符串处理的一些小细节
- Leetcode 110. Balanced Binary Tree
- Maven项目部署到tomcat6(内嵌tomcat6)
- gcc中的-Wl,rpath=<your_lib_dir>选项
- epoll使用详解
- 最好用的vim配置 spf13-vim
- kafka-storm spout拉取数据问题offset out of range
- HDU 4497 GCDandLCM
- 来到博客
- 基础练习 数列特征