
Asked in Jio
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 Software Developer Interview Questions Asked at Jio
Q. Given a singly linked list, reverse the list and return the reversed list.
Q. Count the frequency of letters in a sentence with a method having least time com...read more
Q. Count the occurrences of each element, and if the count is equal to a specified ...read more
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for Jio Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

