Available question text
Given a rooted tree with a character on each node, simultaneously reparent every node (except the root) to its nearest ancestor that has the same character (if any), producing a modified tree. Return the sizes of all subtrees in that final tree — the core challenge is efficiently finding nearest same-letter ancestors for all nodes and computing subtree sizes under n up to 1e5.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 3331. Find Subtree Sizes After Changes
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source