Problem 1245 · Medium

Tree Diameter

Sweep the tree from any node to find one end of a longest path, then sweep again from that end.

Open the interactive visualisation