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
Links
GeeksforGeeks
ProgramCreek
Examples
Input: [1, 2, 3, 4, 5, null, null, 6, null, null, null, 7]

Output: 5
Input: []
Output: 0
Input: [1]

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

Output: 4
Solutions
Follow up
Last updated
Was this helpful?