Problem 1519 · Medium

Number of Nodes in the Sub-Tree With the Same Label

Root the tree and combine letter counts from the children bottom-up, reading each node’s own label count.

Open the interactive visualisation