Back to problems Sign in to unlock
Leetcode
Easy
Trees
Math
Root Equals Sum Of Children
Check whether the root value of a binary tree equals the sum of its two children.
Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement
Problem
You are given the root of a binary tree with exactly three nodes: a root node and its left and right children.
Determine whether the value stored at the root is equal to the sum of the values stored in its two children.
Return true if the equality holds, otherwise return false.
Notes
- The tree is guaranteed to have the root, left child, and right child.
- Node values may be positive, zero, or negative.
- This is a simple verification problem intended to test basic tree traversal and condition checking.
Input Format
- A binary tree root with a root node and two child nodes.
- Each node contains an integer value.
Output Format
- Return a boolean value.
trueifroot.val == root.left.val + root.right.val, otherwisefalse.
Constraints
- The tree has exactly 3 nodes.
- Each node value fits in a standard 32-bit signed integer.
- The left and right children of the root are both present.
Examples
Sample cases returned by the problem API.
Example 1
Input
root = [10, 4, 6]
Output
true
Explanation
The root value is 10 and the sum of its children is 4 + 6 = 10.
Example 2
Input
root = [5, 3, 1]
Output
false
Explanation
The root value is 5 but the sum of its children is 3 + 1 = 4.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.
Guided hints
Editorial and discussion links
Concept map and variants
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.