1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/检查子树 [check-subtree-lcci].html
2022-03-29 12:43:11 +08:00

26 lines
794 B
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>检查子树。你有两棵非常大的二叉树T1有几万个节点T2有几万个节点。设计一个算法判断 T2 是否为 T1 的子树。</p>
<p>如果 T1 有这么一个节点 n其子树与 T2 一模一样,则 T2 为 T1 的子树,也就是说,从节点 n 处把树砍断,得到的树与 T2 完全相同。</p>
<p><strong>注意:</strong>此题相对书上原题略有改动。</p>
<p><strong>示例1:</strong></p>
<pre>
<strong> 输入</strong>t1 = [1, 2, 3], t2 = [2]
<strong> 输出</strong>true
</pre>
<p><strong>示例2:</strong></p>
<pre>
<strong> 输入</strong>t1 = [1, null, 2, 4], t2 = [3, 2]
<strong> 输出</strong>false
</pre>
<p><strong>提示:</strong></p>
<ol>
<li>树的节点数目范围为[0, 20000]。</li>
</ol>