Tap here to switch tabs
Problem
Submissions

Problem: Count Nodes Equal to Sum of Descendants

Try to solve the Count Nodes Equal to Sum of Descendants problem.

Statement

Given the root of a binary tree, return the number of nodes where the value of the node equals the total sum of the values of all its descendants.

A descendant of a node is any node situated strictly below it along a path leading to a leaf node. A node with no descendants has a descendant sum of 00.

Note: A node is not considered a descendant of itself.

Constraints:

  • The number of nodes in the tree is in the range [11, 10510^5].

  • 0≤0 \leq Node.val ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Nodes Equal to Sum of Descendants

Try to solve the Count Nodes Equal to Sum of Descendants problem.

Statement

Given the root of a binary tree, return the number of nodes where the value of the node equals the total sum of the values of all its descendants.

A descendant of a node is any node situated strictly below it along a path leading to a leaf node. A node with no descendants has a descendant sum of 00.

Note: A node is not considered a descendant of itself.

Constraints:

  • The number of nodes in the tree is in the range [11, 10510^5].

  • 0≤0 \leq Node.val ≤105\leq 10^5