← 返回 bytedance 的题目列表Binary Tree Diameter
类型:online_judge
Given a binary tree, return the diameter of the tree (the number of nodes on the longest path between any two nodes).
Input Format
The input is represented as a binary tree structure.
Output Format
An integer representing the diameter of the binary tree.
Example
Input:
[1,2,3,4,5]
Output:
4
Constraints
The number of nodes is between 1 and 10000.
Example
Input
[1,2,3,4,5]