Given a connected, undirected tree with N nodes, find the maximum diameter, defined as the longest simple path between any two nodes.
Explanation: The longest path is from node 1 to node 4 with a length of 3: 1 -> 2 -> 3 -> 4
Dynamic programming over tree structures
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak