Check that each tree node equals its subtree's average

0
Remix

For a binary tree, decide whether every node's value equals the average of the values in its subtree (or of the nodes below it, as the interviewer defines it), or count the nodes for which that holds. A post-order walk that returns each subtree's sum and size does it in one pass.

MetaCodingLast asked Sep 2025
No answer yet. Write the first one; the best answer gets endorsed.