1973. Count Nodes Equal to Sum of Descendants
Previous1972. First and Last Call On the Same DayNext1974. Minimum Time to Type Word Using Special Typewriter
Last updated
Was this helpful?
Last updated
Was this helpful?
https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants
Given the root
of a binary tree, return the number of nodes where the value of the node is equal to the sum of the values of its descendants.
A descendant of a node x
is any node that is on the path from node x
to some leaf node. The sum is considered to be 0
if the node has no descendants.
Example 1:
Example 2:
Example 3:
Constraints:
The number of nodes in the tree is in the range [1, 105]
.
0 <= Node.val <= 105