Loading...
Given the root of a binary tree (as a level-order array), return the diameter — the length of the longest path between any two nodes.
The length is measured by the number of edges between them.
1,2,3,4,5
3
1 is the root, 2 and 3 are its children, and 4 and 5 are children of 2 and 3 respectively.4 to 5, passing through 2 and 3, and the root 1.