mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	国外版
This commit is contained in:
		
							
								
								
									
										26
									
								
								算法题(国外版)/two-sum-iv-input-is-a-bst.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								算法题(国外版)/two-sum-iv-input-is-a-bst.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
<p>Given the <code>root</code> of a Binary Search Tree and a target number <code>k</code>, return <em><code>true</code> if there exist two elements in the BST such that their sum is equal to the given target</em>.</p>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Example 1:</strong></p>
 | 
			
		||||
<img alt="" src="https://assets.leetcode.com/uploads/2020/09/21/sum_tree_1.jpg" style="width: 400px; height: 229px;" />
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> root = [5,3,6,2,4,null,7], k = 9
 | 
			
		||||
<strong>Output:</strong> true
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 2:</strong></p>
 | 
			
		||||
<img alt="" src="https://assets.leetcode.com/uploads/2020/09/21/sum_tree_2.jpg" style="width: 400px; height: 229px;" />
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> root = [5,3,6,2,4,null,7], k = 28
 | 
			
		||||
<strong>Output:</strong> false
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Constraints:</strong></p>
 | 
			
		||||
 | 
			
		||||
<ul>
 | 
			
		||||
	<li>The number of nodes in the tree is in the range <code>[1, 10<sup>4</sup>]</code>.</li>
 | 
			
		||||
	<li><code>-10<sup>4</sup> <= Node.val <= 10<sup>4</sup></code></li>
 | 
			
		||||
	<li><code>root</code> is guaranteed to be a <strong>valid</strong> binary search tree.</li>
 | 
			
		||||
	<li><code>-10<sup>5</sup> <= k <= 10<sup>5</sup></code></li>
 | 
			
		||||
</ul>
 | 
			
		||||
		Reference in New Issue
	
	Block a user