Skip to content

Practice Root Equals Sum of Children

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2236
LeetCode Problem

Root Equals Sum of Children

Problem Statement

You are given the root of a binary tree that consists of exactly 3 nodes: the root, its left child, and its right child. Return true if the value of the root is equal to the sum of the values of its two children, or false otherwise.

Source: Root Equals Sum of Children on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
root = [10,4,6]
Output
true

# Example 2

Input
root = [5,3,1]
Output
false

Constraints

The tree consists only of the root, its left child, and its right child.
-100 <= Node.val <= 100

Related LeetCode Problems

Practice more problems similar to Root Equals Sum of Children.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.