Leaderboard
Showing:
Handle Score
@Ibrahim Nash 5725
@blackshadows 5685
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Complete Leaderboard
Triplet with 0 sum in BST
Easy Accuracy: 45.15% Submissions: 3281 Points: 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

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Triplet with 0 sum in BST

Output Window