Back
Diameter of Binary Tree
Given the root of a binary tree, return the length of the diameter of the tree.
Java
Description
Solution
My Code
Diameter of Binary Tree
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
Viz
Tests
Run
Input
Example 1
Example 2
Custom
{"root":[1,2,3,4,5]}
arr =
{"root":[1,2,3,4,5]}
Diameter
0
1
2
3
4
5
Variables
Variable
Value
diameter
0
Depth
Function Call
Stack empty
0/27
0.5x
1x
2x
4x