Largest Proper Subtree
Rooted at node 1, print the size (node count) of the largest subtree hanging below the root — i.e. the largest subtree of any non-root node.
Input: the first line has N (N ≥ 2); each of the next N−1 lines has an edge u v.
Output: the maximum subtree size among non-root nodes.
Constraints:
- 2 ≤ N ≤ 105
Sample Tests
Input 1
5 1 2 2 3 2 4 1 5
Output 1
3
Input 2
2 1 2
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.