Tap here to switch tabs
Problem
Submissions

Problem: Count Nodes Equal to Average of Subtree

Try to solve the Count Nodes Equal to Average of Subtree problem.

Statement

Given the root of a binary tree, return the number of nodes where the value of the node is equal to the average of the values in its subtree.

Note: The average of nn elements is the sum of the nn elements divided by nn, rounded down to the nearest integer. A subtree of a node includes the node itself along with all of its descendants.

Constraints:

  • The number of nodes in the tree is in the range [1,1000][1, 1000].

  • 0≤0 \leq Node.val ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Nodes Equal to Average of Subtree

Try to solve the Count Nodes Equal to Average of Subtree problem.

Statement

Given the root of a binary tree, return the number of nodes where the value of the node is equal to the average of the values in its subtree.

Note: The average of nn elements is the sum of the nn elements divided by nn, rounded down to the nearest integer. A subtree of a node includes the node itself along with all of its descendants.

Constraints:

  • The number of nodes in the tree is in the range [1,1000][1, 1000].

  • 0≤0 \leq Node.val ≤1000\leq 1000