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 = distance between A and B
Use DP to store max depths at each node
Calculate max diameter using depths
Return diameter
Find the tree diameter by two DFS traversals and use DP to store max depths for efficient calculation.
