#3249
Count the Number of Good Nodes
specialist · 810 · lc medium +31 · 55.3% accepted · 178 likes · top 48%
Description
An undirected tree rooted at node 0 has n nodes (0 to n - 1) with edges in edges. A node is good if all its children's subtrees have the same size.
Return the count of good nodes.
Code
1
2
3