Class Solution
-
- All Implemented Interfaces:
public final class Solution653 - Two Sum IV - Input is a BST\.
Easy
Given the
rootof a binary search tree and an integerk, returntrueif there exist two elements in the BST such that their sum is equal tok, orfalseotherwise.Example 1:
Input: root = 5,3,6,2,4,null,7, k = 9
Output: true
Example 2:
Input: root = 5,3,6,2,4,null,7, k = 28
Output: false
Constraints:
The number of nodes in the tree is in the range <code>1, 10<sup>4</sup></code>.
<code>-10<sup>4</sup><= Node.val <= 10<sup>4</sup></code>
rootis guaranteed to be a valid binary search tree.<code>-10<sup>5</sup><= k <= 10<sup>5</sup></code>
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final BooleanfindTarget(TreeNode root, Integer k)-
-
Method Detail
-
findTarget
final Boolean findTarget(TreeNode root, Integer k)
-
-
-
-