Given a binary tree where each node has a unique value, find the diameter of the tree, which is defined as the length of the longest path between any two leaf nodes.
Explanation: The longest path is through the nodes with values 3, 2, and 4, which has a length of 3.
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak