
Triple Sum Problem Statement
Bojack wants to gift Todd a binary tree with N
nodes for his birthday. However, the tree is too large, so he decides to select exactly three nodes such that their sum equals a given integer X
. Help Bojack determine if such a selection of nodes is possible.
Input:
1. An integer T
representing the number of test cases.
2. For each test case:
- The elements of the binary tree in level order, separated by spaces.
- An integer X
.
Output:
A boolean True or False for each test case, indicating the possibility of obtaining the sum X
using values from any three nodes.
Example:
Input:
T = 1
Nodes = [2, 3, -1, 4, -1, -1, 5, -1, -1, -1]
X = 11
Output:
True
Explanation:
The nodes with values 7, 3, and 1 add up to 11, making it possible to form the sum X
.
Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 3000
1 ≤ NodeVal ≤ 1000
1 ≤ X ≤ 1000
- Time Limit: 1sec
Note:
You do not need to print anything. Just implement the function and return the correct output.

AnswerBot
1y

The task is to determine if it is possible to select three nodes from a binary tree such that their sum equals a given value.
Traverse the binary tree and store all the node values in an array
Use three...read more

Help your peers!
Add answer anonymously...
Top Jio Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app