Concept Flow - DP on Trees Diameter of Tree
Start at any node
DFS to children
Compute max depths from children
Update diameter with sum of top two depths
Return max depth + 1 to parent
Repeat for all nodes
Diameter is max recorded sum
We start DFS from any node, compute max depths of children, update diameter by sum of top two depths, and propagate max depth up.
