1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/单值二叉树 [univalued-binary-tree].html
2022-03-29 12:43:11 +08:00

31 lines
1.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>如果二叉树每个节点都具有相同的值,那么该二叉树就是<em>单值</em>二叉树。</p>
<p>只有给定的树是单值二叉树时,才返回&nbsp;<code>true</code>;否则返回 <code>false</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2018/12/29/screen-shot-2018-12-25-at-50104-pm.png" style="height: 159px; width: 200px;"></p>
<pre><strong>输入:</strong>[1,1,1,1,1,null,1]
<strong>输出:</strong>true
</pre>
<p><strong>示例 2</strong></p>
<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2018/12/29/screen-shot-2018-12-25-at-50050-pm.png" style="height: 158px; width: 200px;"></p>
<pre><strong>输入:</strong>[2,2,2,5,2]
<strong>输出:</strong>false
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ol>
<li>给定树的节点数范围是&nbsp;<code>[1, 100]</code></li>
<li>每个节点的值都是整数,范围为&nbsp;<code>[0, 99]</code>&nbsp;</li>
</ol>