← Questions

Check that each tree node equals its subtree's average

0
MetaCodingLast asked Sep 2025

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.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding