Search
⌘K

Leetcode 1519. Number of Nodes in the Sub-Tree With the Same Label

Given a rooted tree with a lowercase label on each node, return for every node how many nodes in its subtree have the same label; the core challenge is to aggregate label frequencies across subtrees (typically via a postorder DFS) to compute each count efficiently for n up to 1e5.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.