Algorithm · Snowflake · Easy
Problem: Verify That the Root Matches Every Subtree Average (Variant) You receive a binary tree named root, with an integer stored in each node. For a node x, its subtree includes x together with every descendant beneath it. The average for that subtree is the arithmetic mean of the values held by all nodes in it. Decide whether root.val is identical to the average of each node's subtree across the entire tree. Return true when every node x satisfies avg(subtree(x)) ==…
Checking your access…