
Root Equals Sum of Children (easy)
Problem Statement
Given a binary tree with exactly 3 nodes (single root and two child nodes), determine if the root's value is equal to the sum of the child nodes values.
Examples
-
Example 1:
- Input: root = [10, 3, 7]
- Expected Output: true
- Justification: The root's value (10) is equal to the sum of its children's values (3 + 7).
-
Example 2:
- Input: root = [4, 1, 5]
- Expected Output: false
- Justification: The root's value (4) is not equal to the sum of its children's values (1 + 5).
-
Example 3:
- Input: root = [15, 10, 5]
- Expected Output: true
- Justification: The root's value (15) is equal to the sum of its children's values (10 + 5).
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Unlock this and all other premium problems.
No code editor for this lesson
This lesson focuses on concepts and theory