Find a pair with given target in BST
Submissions: 6946   Accuracy:

33.42%

  Difficulty: Medium   Marks: 4
Associated Course(s):   Interview Preparation
     

Given a Binary Search Tree and a target sum, write a function that returns true if there is a pair with sum equals to target sum, otherwise return false.

Input:
First line consists of T test cases. First line of every test case consists of N and target, denoting the number of elements in bst and target sum. Second line consists of elements of BST.

Output:
Return True if target sum pair is found else False.

Constraints:
1<=T<=100
1<=N<=100

Example:
Input:

2
7 10
1 2 3 4 5 6 7
7 33
15 10 20 8 12 16 25  
Output:
1
1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth
Author: saksham seth


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.