mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-12-21 03:13:45 +08:00
update
This commit is contained in:
@@ -2,8 +2,12 @@
|
||||
|
||||
<ol>
|
||||
<li><code>root.val == 0</code></li>
|
||||
<li>如果 <code>treeNode.val == x</code> 且 <code>treeNode.left != null</code>,那么 <code>treeNode.left.val == 2 * x + 1</code></li>
|
||||
<li>如果 <code>treeNode.val == x</code> 且 <code>treeNode.right != null</code>,那么 <code>treeNode.right.val == 2 * x + 2</code></li>
|
||||
<li>对于任意 <code>treeNode</code>:
|
||||
<ol type="a">
|
||||
<li>如果 <code>treeNode.val</code> 为 <code>x</code> 且 <code>treeNode.left != null</code>,那么 <code>treeNode.left.val == 2 * x + 1</code></li>
|
||||
<li>如果 <code>treeNode.val</code> 为 <code>x</code> 且 <code>treeNode.right != null</code>,那么 <code>treeNode.right.val == 2 * x + 2</code></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<p>现在这个二叉树受到「污染」,所有的 <code>treeNode.val</code> 都变成了 <code>-1</code>。</p>
|
||||
@@ -17,12 +21,13 @@
|
||||
|
||||
<p> </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>
|
||||
["FindElements","find","find"]
|
||||
<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>
|
||||
["FindElements","find","find","find"]
|
||||
<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>
|
||||
["FindElements","find","find","find","find"]
|
||||
<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>二叉树的高度不超过 <code>20</code></li>
|
||||
<li>节点的总数在 <code>[1, 10^4]</code> 之间</li>
|
||||
<li>调用 <code>find()</code> 的总次数在 <code>[1, 10^4]</code> 之间</li>
|
||||
<li><code>0 <= target <= 10^6</code></li>
|
||||
<li>节点的总数在 <code>[1, 10<sup>4</sup>]</code> 之间</li>
|
||||
<li>调用 <code>find()</code> 的总次数在 <code>[1, 10<sup>4</sup>]</code> 之间</li>
|
||||
<li><code>0 <= target <= 10<sup>6</sup></code></li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user