Triplet with 0 sum in BST
Submissions: 2028   Accuracy:

43.97%

  Difficulty: Easy   Marks: 2

Given a Binary Search Tree (BST), write a function isTripletPresent() that returns true if there is a triplet in given BST with sum equals to 0, otherwise returns false.

Input:
First line consists of T test case. First line of every test case consists of N, denoting the number of nodes in bst. Second line of every test case consists of nodes.

Output:
Single line output, return true if triplet found else false.

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

Example:
Input:

2
5
5 -8 -2 10 11
4
1 3 -2 0 5
Output:
1
0

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

Contributor: Saksham Raj Seth
Author: saksham seth


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



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


to report an issue on this page.