mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
32 lines
1.0 KiB
HTML
32 lines
1.0 KiB
HTML
<p>输入一棵二叉树的根节点,判断该树是不是平衡二叉树。如果某二叉树中任意节点的左右子树的深度相差不超过1,那么它就是一棵平衡二叉树。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>root = [3,9,20,null,null,15,7]
|
||
<strong>输出:</strong>true
|
||
<strong>解释:</strong>如下图
|
||
</pre>
|
||
|
||
<p><img alt="" src="https://pic.leetcode.cn/1695102431-vbmWJn-image.png" style="height: 281px; width: 500px;" /><br />
|
||
<br />
|
||
<strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
输入:root = [1,2,2,3,3,null,null,4,4]
|
||
输出:false
|
||
解释:如下图
|
||
</pre>
|
||
<img alt="" src="https://pic.leetcode.cn/1695102434-WlaxCo-image.png" style="height: 281px; width: 500px;" />
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>0 <= 树的结点个数 <= 10000</code></li>
|
||
</ul>
|
||
|
||
<p>注意:本题与主站 110 题相同:<a href="https://leetcode-cn.com/problems/balanced-binary-tree/">https://leetcode-cn.com/problems/balanced-binary-tree/</a></p>
|