1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/两数之和 IV - 输入二叉搜索树 [two-sum-iv-input-is-a-bst].html

29 lines
1.1 KiB
HTML
Raw Normal View History

2023-12-09 18:42:21 +08:00
<p>给定一个二叉搜索树 <code>root</code> 和一个目标结果 <code>k</code>,如果二叉搜索树中存在两个元素且它们的和等于给定的目标结果,则返回 <code>true</code></p>
2022-03-27 20:46:41 +08:00
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/09/21/sum_tree_1.jpg" style="height: 229px; width: 400px;" />
<pre>
<strong>输入:</strong> root = [5,3,6,2,4,null,7], k = 9
<strong>输出:</strong> true
</pre>
<p><strong>示例 2</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/09/21/sum_tree_2.jpg" style="height: 229px; width: 400px;" />
<pre>
<strong>输入:</strong> root = [5,3,6,2,4,null,7], k = 28
<strong>输出:</strong> false
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li>二叉树的节点个数的范围是&nbsp;&nbsp;<code>[1, 10<sup>4</sup>]</code>.</li>
<li><code>-10<sup>4</sup>&nbsp;&lt;= Node.val &lt;= 10<sup>4</sup></code></li>
2023-12-09 18:42:21 +08:00
<li>题目数据保证,输入的 <code>root</code> 是一棵 <strong>有效</strong> 的二叉搜索树</li>
2022-03-27 20:46:41 +08:00
<li><code>-10<sup>5</sup>&nbsp;&lt;= k &lt;= 10<sup>5</sup></code></li>
</ul>