Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Start at any node A and traverse the tree to find the furthest node from it, let's call it B.
Having found the furthest node B, traverse the tree from B to find the furthest node from it, lets call it C.
The distance between B and C is the tree diameter.