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)/树的子结构 [shu-de-zi-jie-gou-lcof].html
2022-03-29 12:43:11 +08:00

34 lines
889 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>输入两棵二叉树A和B判断B是不是A的子结构。(约定空树不是任意一个树的子结构)</p>
<p>B是A的子结构 即 A中有出现和B相同的结构和节点值。</p>
<p>例如:<br>
给定的树 A:</p>
<p><code>&nbsp; &nbsp; &nbsp;3<br>
&nbsp; &nbsp; / \<br>
&nbsp; &nbsp;4 &nbsp; 5<br>
&nbsp; / \<br>
&nbsp;1 &nbsp; 2</code><br>
给定的树 B</p>
<p><code>&nbsp; &nbsp;4&nbsp;<br>
&nbsp; /<br>
&nbsp;1</code><br>
返回 true因为 B 与 A 的一个子树拥有相同的结构和节点值。</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>A = [1,2,3], B = [3,1]
<strong>输出:</strong>false
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>A = [3,4,5,1,2], B = [4,1]
<strong>输出:</strong>true</pre>
<p><strong>限制:</strong></p>
<p><code>0 &lt;= 节点个数 &lt;= 10000</code></p>