← 返回 citadel 的题目列表Find the Longest Path in a Tree (Tree Diameter)
类型:online_judge
Given a tree, find its longest path.
Input: The number of nodes n and a list of edges edges, where each edge is a tuple (u, v).
Output: Return the length of the tree's longest path.
Example
Input
5
0 1
1 2
1 3
3 4
Output
3