1177. Tree Diameter

Medium
Tree
Depth-First Search
Breadth-First Search
Graph
Topological Sort

Description

Hints

Hint 1
Start at any node A and traverse the tree to find the furthest node from it, let's call it B.
Hint 2
Having found the furthest node B, traverse the tree from B to find the furthest node from it, lets call it C.
Hint 3
The distance between B and C is the tree diameter.

Statistics

Acceptance
61.2%
Submissions
90,702
Accepted
55,542