1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-12-21 03:13:45 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2025-09-29 14:43:44 +08:00
parent 2862a227c4
commit 13f2098086
4409 changed files with 168933 additions and 166256 deletions

View File

@@ -2,8 +2,12 @@
<ol>
<li><code>root.val == 0</code></li>
<li>如果 <code>treeNode.val == x</code>&nbsp;<code>treeNode.left != null</code>,那么&nbsp;<code>treeNode.left.val == 2 * x + 1</code></li>
<li>如果 <code>treeNode.val == x</code><code>treeNode.right != null</code>,那么&nbsp;<code>treeNode.right.val == 2 * x + 2</code></li>
<li>对于任意 <code>treeNode</code>
<ol type="a">
<li>如果 <code>treeNode.val</code>&nbsp;<code>x</code>&nbsp;<code>treeNode.left != null</code>,那么&nbsp;<code>treeNode.left.val == 2 * x + 1</code></li>
<li>如果 <code>treeNode.val</code>&nbsp;<code>x</code><code>treeNode.right != null</code>,那么&nbsp;<code>treeNode.right.val == 2 * x + 2</code></li>
</ol>
</li>
</ol>
<p>现在这个二叉树受到「污染」,所有的&nbsp;<code>treeNode.val</code>&nbsp;都变成了&nbsp;<code>-1</code></p>
@@ -17,12 +21,13 @@
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<p><strong class="example">示例 1</strong></p>
<p><strong><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2019/11/16/untitled-diagram-4-1.jpg" style="height: 119px; width: 320px;"></strong></p>
<p><strong><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2019/11/16/untitled-diagram-4-1.jpg" style="height: 119px; width: 320px;" /></strong></p>
<pre><strong>输入:</strong>
[&quot;FindElements&quot;,&quot;find&quot;,&quot;find&quot;]
<pre>
<strong>输入:</strong>
["FindElements","find","find"]
[[[-1,null,-1]],[1],[2]]
<strong>输出:</strong>
[null,false,true]
@@ -31,12 +36,13 @@ FindElements findElements = new FindElements([-1,null,-1]);
findElements.find(1); // return False
findElements.find(2); // return True </pre>
<p><strong>示例 2</strong></p>
<p><strong class="example">示例 2</strong></p>
<p><strong><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2019/11/16/untitled-diagram-4.jpg" style="height: 198px; width: 400px;"></strong></p>
<p><strong><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2019/11/16/untitled-diagram-4.jpg" style="height: 198px; width: 400px;" /></strong></p>
<pre><strong>输入:</strong>
[&quot;FindElements&quot;,&quot;find&quot;,&quot;find&quot;,&quot;find&quot;]
<pre>
<strong>输入:</strong>
["FindElements","find","find","find"]
[[[-1,-1,-1,-1,-1]],[1],[3],[5]]
<strong>输出:</strong>
[null,true,true,false]
@@ -46,12 +52,13 @@ findElements.find(1); // return True
findElements.find(3); // return True
findElements.find(5); // return False</pre>
<p><strong>示例 3</strong></p>
<p><strong class="example">示例 3</strong></p>
<p><strong><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2019/11/16/untitled-diagram-4-1-1.jpg" style="height: 274px; width: 306px;"></strong></p>
<p><strong><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2019/11/16/untitled-diagram-4-1-1.jpg" style="height: 274px; width: 306px;" /></strong></p>
<pre><strong>输入:</strong>
[&quot;FindElements&quot;,&quot;find&quot;,&quot;find&quot;,&quot;find&quot;,&quot;find&quot;]
<pre>
<strong>输入:</strong>
["FindElements","find","find","find","find"]
[[[-1,null,-1,-1,null,-1]],[2],[3],[4],[5]]
<strong>输出:</strong>
[null,true,false,false,true]
@@ -70,7 +77,7 @@ findElements.find(5); // return True
<ul>
<li><code>TreeNode.val == -1</code></li>
<li>二叉树的高度不超过&nbsp;<code>20</code></li>
<li>节点的总数在&nbsp;<code>[1,&nbsp;10^4]</code>&nbsp;之间</li>
<li>调用&nbsp;<code>find()</code>&nbsp;的总次数在&nbsp;<code>[1,&nbsp;10^4]</code>&nbsp;之间</li>
<li><code>0 &lt;= target &lt;= 10^6</code></li>
<li>节点的总数在&nbsp;<code>[1,&nbsp;10<sup>4</sup>]</code>&nbsp;之间</li>
<li>调用&nbsp;<code>find()</code>&nbsp;的总次数在&nbsp;<code>[1,&nbsp;10<sup>4</sup>]</code>&nbsp;之间</li>
<li><code>0 &lt;= target &lt;= 10<sup>6</sup></code></li>
</ul>