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 n elements is the sum of the n elements divided by n and rounded down to the nearest integer. - A subtree of root is a tree consisting of root and all of its descendants.
Example 1
Input: root = [4,8,5,0,1,null,6]
Output: 5
Explanation: Nodes 4, 5, 0, 1 and 6 each equal the floor average of their own subtree; node 8 (avg 3) does not. Answer is 5.
Example 2
Input: root = [1]
Output: 1
Explanation: A single node's subtree is itself, so it always equals its own average.
Example 3
Input: root = [0]
Output: 1
Explanation: A single node's subtree is just itself, and 0 / 1 = 0 equals its value, so the count is 1.
A node's subtree average can only be known once its children have reported their own subtree totals, so do the work on the way back up: each call returns the (sum, size) of its subtree.
Run checks all cases above. Submit evaluates all test cases.