Question: Recently, Tan started learning about trees, especially Explanation In a given array Consider A = 1 , B = 2 , and C = 3
Recently, Tan started learning about trees, especially Explanation
In a given array Consider and
Compute the sum of and : Compute
half of this sum: not valid
Compute the sum of A and : Compute
half of this sum: valid Sample Output
Explanation
In a given array Consider and
Compute the sum and : Compute
half of this sum: not valid
Compute the sum of A and : Compute
half of this sum: valid
valid because is present as a remaining element.
Compute the sum of A and : Compute
half of this sum: not valid
So the output will be
Binary Trees. He started thinking of creating a binary
tree that has precisely three nodes. One will be the
root node, and the other will be its child nodes. But the
condition is that the root node's value be equal to half
of the sum of the value of its child nodes.
He asked Taru to give him integers to create this kind
of binary tree. Seeing all those integers, Tan got
overwhelmed, so he needs your help finding any three
integers that can be created as a tree. Since many
possible combinations exist, you must tell the number
of triplets that can form the above binary tree.
Input Format
The first line will contain an integer
The next line will contain an integer each.
Constraints
array element
Output Format
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
