 Children Sum Parent
##### Submissions: 9823   Accuracy: 52.13%   Difficulty: Easy   Marks: 2

Given a binary tree, complete the function that returns true if the tree satisfies the following property:
For every node, data value must be equal to the sum of data values in left and right children. Consider data value as 0 for NULL child.  Also, leaves are considered to follow the property.

Input Format:
First line of input contains the number of test cases T. For each test case, there will be only a single line of input which is a string representing the tree as described below:

1. The values in the string are in the order of level order traversal of the tree where, numbers denotes node values, and a character “N” denotes NULL child.

2. For example: For the above tree, the string will be: 1 2 3 N N 4 6 N 5 N N 7 N

Output Format:
Return 1 if the given tree satisfies the given property else return 0.

This is a function problem. You need to only complete the given function isSumProperty() that returns 0 or 1. The printing is done by the driver code.

Constraints:
1 <= T <= 100
1 <= N <= 100
1 <= Data on nodes <= 1000

Example:
Input:

2
10 10
1 4 3 5 N

Output:
1
0

Explanation:
Testcase 1:
Tree is like:
10
/
10

Here, every node is sum of its left and right child.

Note: The Input/Output format and Example given are used for the system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from the stdin/console. The task is to complete the function specified, and not to write the full code.

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

Contributor: Shashwat Jain
Author: shashwat jain

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.