Diameter of Binary Tree
Given the root of a binary tree, return the length of the diameter of the tree.

30:00

Diameter of Binary Tree
easy
Topics
Companies

Given the root of a binary tree, return the length of the diameter of the tree.

Example 1:
Input: {"root":[1,2,3,4,5]}
Output: 3
Constraints:
  • The number of nodes is in the range [1,104][1, 10^4].

  • 100Node.val100-100 \leq \text{Node.val} \leq 100

Input
arr ={"root":[1,2,3,4,5]}
Diameter
0

1

2

3

4

5

Variables
VariableValue
diameter0
DepthFunction Call
Stack empty
0/27