Given the root of a binary tree, find the length of the diameter. The diameter is the longest path between any two nodes, measured in edges. This path may or may not pass through the root. Meta frequently asks this to test your ability to compute tree properties with a single DFS pass.
For example, in a tree [1,2,3,4,5], the diameter is : the path .
The answer isn't always the sum of left and right depths from the root. Why not? Think about a tree where the longest path lives entirely in one subtree.
Constraints: number of nodes .