Mental Model
The diameter of a tree is the longest path between any two nodes. We find it by checking the longest paths through each node using dynamic programming.
Analogy: Imagine a network of roads connecting towns. The diameter is the longest route you can travel without repeating roads. We find it by looking at the longest roads from each town and combining them.
1 / \ 2 3 / \ 4 5 Each number is a town (node), lines are roads (edges).
