Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
For each node, you need to find the sizes of the subtrees rooted in each of its children. Maybe DFS?
How to determine the number of nodes in the rest of the tree? Can you subtract the size of the subtree rooted at the node from the total number of nodes of the tree?
Use these values to compute the score of the node. Track the maximum score, and how many nodes achieve such score.