Count Nodes Equal to Average of Subtree
Medium · Trees · about 15 minutes
Asked at Meta, Amazon, Google, Snowflake.
Return the number of nodes whose value equals the average of the values in their subtree (the node and all its descendants), with the average rounded down to an integer.