mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
38 lines
1.1 KiB
HTML
38 lines
1.1 KiB
HTML
|
<p>请实现一个函数,用来判断一棵二叉树是不是对称的。如果一棵二叉树和它的镜像一样,那么它是对称的。</p>
|
|||
|
|
|||
|
<p>例如,二叉树 [1,2,2,3,4,4,3] 是对称的。</p>
|
|||
|
|
|||
|
<p><code> 1<br>
|
|||
|
/ \<br>
|
|||
|
2 2<br>
|
|||
|
/ \ / \<br>
|
|||
|
3 4 4 3</code><br>
|
|||
|
但是下面这个 [1,2,2,null,3,null,3] 则不是镜像对称的:</p>
|
|||
|
|
|||
|
<p><code> 1<br>
|
|||
|
/ \<br>
|
|||
|
2 2<br>
|
|||
|
\ \<br>
|
|||
|
3 3</code></p>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>示例 1:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>root = [1,2,2,3,4,4,3]
|
|||
|
<strong>输出:</strong>true
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>示例 2:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>root = [1,2,2,null,3,null,3]
|
|||
|
<strong>输出:</strong>false</pre>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>限制:</strong></p>
|
|||
|
|
|||
|
<p><code>0 <= 节点个数 <= 1000</code></p>
|
|||
|
|
|||
|
<p>注意:本题与主站 101 题相同:<a href="https://leetcode-cn.com/problems/symmetric-tree/">https://leetcode-cn.com/problems/symmetric-tree/</a></p>
|