Two Sum IV – Input Is a BST
Try to solve the Two Sum IV – Input Is a BST problem.
We'll cover the following
Statement
Given the root
of a binary search tree and an integer k
, determine whether there are two elements in the BST whose sum equals k
. Return TRUE if such elements exist or FALSE otherwise.
Constraints:
The number of nodes in the tree is in the range
. Node.data
root
is guaranteed to be a valid binary search tree.k
Examples
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.