Mental Model
The diameter of a tree is the longest path between any two nodes. We find it by exploring the longest paths from each node using dynamic programming.
Analogy: Imagine a network of roads connecting cities (nodes). The diameter is the longest route you can drive without repeating roads. To find it, you check the longest routes starting from each city and combine them.
1 / \ 2 3 / \ 4 5 Nodes connected like a tree with branches.
