mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
38 lines
949 B
HTML
38 lines
949 B
HTML
<p>给你一棵二叉树的根节点 <code>root</code> ,翻转这棵二叉树,并返回其根节点。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<p><img alt="" src="https://assets.leetcode.com/uploads/2021/03/14/invert1-tree.jpg" style="height: 165px; width: 500px;" /></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>root = [4,2,7,1,3,6,9]
|
||
<strong>输出:</strong>[4,7,2,9,6,3,1]
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<p><img alt="" src="https://assets.leetcode.com/uploads/2021/03/14/invert2-tree.jpg" style="width: 500px; height: 120px;" /></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>root = [2,1,3]
|
||
<strong>输出:</strong>[2,3,1]
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>root = []
|
||
<strong>输出:</strong>[]
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li>树中节点数目范围在 <code>[0, 100]</code> 内</li>
|
||
<li><code>-100 <= Node.val <= 100</code></li>
|
||
</ul>
|