← ALL NOTES
Tree

2265. Count Nodes Equal to Average of Subtree

Every node needs two facts about its subtree — the total value and the node count — and both roll up cleanly from its children, so a single post-order pass that returns {sum, count} settles the whole tree.

Loading…