Practice Count Nodes Equal to Average of Subtree
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Count nodes whose value equals the average of all values in their subtree, including the node itself and every descendant. Divide the subtree sum by its number of nodes and round down before comparing.
Source: Count Nodes Equal to Average of Subtree on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
root = [4,8,5,0,1,null,6]
Output
5
# Example 2
Input
root = [1]
Output
1
Constraints
The number of nodes in the tree is in the range [1, 1000].
0 <= Node.val <= 1000
Related LeetCode Problems
Practice more problems similar to Count Nodes Equal to Average of Subtree.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.