Concept Flow - DP on Trees Diameter of Tree
Start at any node
Run DFS to find farthest node A
Run DFS from node A to find farthest node B
Diameter is distance between A and B
Use DP to store max depths during DFS
Update diameter with max sum of two depths at each node
Return final diameter
Find diameter by two DFS traversals and use DP to store max depths for efficient calculation.