Problem Description
Given a binary search tree A, where each node contains a positive integer, and an integer B, you have to find whether or not there exist two different nodes X and Y such that X.value + Y.value = B.
Return 1 to denote that two such nodes exist. Return 0, otherwise.
1 <= size of tree <= 100000
1 <= B <= 109
First argument is the head of the tree A.
Second argument is the integer B.
Return 1 if such a pair can be found, 0 otherwise.
Input 1:
10 / \ 9 20B = 19
Input 2:
10 / \ 9 20B = 40
Output 1:
1
Output 2:
0
Explanation 1:
10 + 9 = 19. Hence 1 is returned.
Explanation 2:
No such pair exists.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.