
Tree Diameter (easy)
Problem Statement
Given a binary tree, find the length of its diameter. The diameter of a tree is the number of nodes on the longest path between any two leaf nodes. The diameter of a tree may or may not pass through the root.
Note: You can always assume that there are at least two leaf nodes in the given tree.
Constraints:
- The number of nodes in the tree is in the range [2, 10<sup>4</sup>].
- 0 <= Node.val <= 100
- The tree has at least two leaf nodes.
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Unlock this and all other premium problems.
No code editor for this lesson
This lesson focuses on concepts and theory