70. Tree Diameter
Medium
Return the largest number of edges in a path between any two nodes in the tree. The path does not have to pass through the root; a tree with zero or one node has diameter zero.
Example 1
Input: raiz = [1, 2, 3, 4, 5]
Output: 3
Example 2
Input: raiz = [9]
Output: 0
Constraints
- 0 <= quantidade de nós <= 10^4
TreesDFS
Saved in this browser
Caso 1
raiz =
[1,2,3,4,5]
Expected =
3
Caso 2
raiz =
[9]
Expected =
0
Run checks these 2 cases. Submit runs all 7, including hidden ones.