110. Balanced Binary Tree验证平衡二叉树
来源:互联网 发布:淘宝服装搭配 编辑:程序博客网 时间:2024/06/06 05:03
class Solution(object):
def isBalanced(self, root):
"""
:type root: TreeNode
:rtype: bool
"""
if not root:
return True
left = self.getHight(root.left)
right = self.getHight(root.right)
return abs(left-right) <= 1 and self.isBalanced(root.left) and self.isBalanced(root.right)
def getHight(self,node):
if not node:
return 0
return max(self.getHight(node.left),self.getHight(node.right))+1
阅读全文
0 0
- 110. Balanced Binary Tree验证平衡二叉树
- Balanced Binary Tree 二叉平衡树
- 【LeetCode】Balanced Binary Tree,平衡二叉树
- [LeetCode] Balanced Binary Tree 平衡二叉树
- Leetcode Balanced Binary Tree 平衡二叉树
- 平衡二叉树---Balanced Binary Tree
- lintcode balanced-binary-tree 平衡二叉树
- Balanced Binary Tree(平衡二叉树)
- leetcode 110. Balanced Binary Tree-平衡二叉树|深度遍历
- LeetCode 110. Balanced Binary Tree(平衡二叉树)
- 110. Balanced Binary Tree 平衡二叉树(重点!!)
- 是否是平衡二叉树 110. Balanced Binary Tree
- Leetcode 110. Balanced Binary Tree 平衡二叉树 解题报告
- 110. Balanced Binary Tree (平衡二叉树判断)
- leetcode -- 110. Balanced Binary Tree 【二叉树是否平衡】
- 110. Balanced Binary Tree | 判断是否是平衡二叉树
- 【平衡二叉树】leetcode 110. Balanced Binary Tree
- AVL树(平衡二叉树(Balanced Binary Tree))
- NuttX实时操作系统
- jboss容器,web整站https环境下使用(spring mvc)redirect重定向到http协议问题
- 剑指offer | 训练题51:正则表达式匹配
- MOS管
- 屏幕记录机BB FlashBack v5.26.0发布丨附下载
- 110. Balanced Binary Tree验证平衡二叉树
- Sublime Text-Snippet的使用
- Sublime Text3 安装插件出错 There are no packages available for installation
- Struts2+POI 实现生成Excel文件和下载
- idea --maven project 工具条不见了 maven 项目引进来报错
- Jmeter使用CSV Data Set Config参数化数据不重复的多次循环执行(实现多用户多次抽奖功能)
- 开始记录深度学习以及机器学习的历程
- 如何从头搭建一个搜索引擎_css的使用
- PAT乙级1008. 数组元素循环右移问题 (20)