2126. Count Nodes Equal to Sum of Descendants

Medium
Tree
Depth-First Search
Binary Tree

Description

Hints

Hint 1
Can we reuse previously calculated information?
Hint 2
How can we calculate the sum of the current subtree using the sum of the child's subtree?

Statistics

Acceptance
77.3%
Submissions
20,269
Accepted
15,667