543. Diameter of Binary Tree

Description

Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.

Constraints

Approach

Examples

Input: [1, 2, 3, 4, 5, null, null, 6, null, null, null, 7]

Output: 5

Solutions

Follow up

Last updated

Was this helpful?