Diameter of a Binary Tree
Medium

Problem Statement

Find the length of the longest path between any two nodes in a binary tree. This path may or may not pass through the root.

Examples

1Example 1
Input:
{ "root": [ 1, 2, 3, 4, 5 ] }
Output:
3
2Example 2
Input:
{ "root": [ 1, 2 ] }
Output:
1
3Example 3
Input:
{ "root": [ 1, null, 2, 3, 4, null, null, 5 ] }
Output:
3
Loading...

Sign in to Run Code and Submit