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
Final diameter is max found
We start DFS from any node, compute max depths of children, update diameter by sum of top two depths, and propagate max depth up to parent until all nodes are processed.
