← 返回 meta 的题目列表Diameter of Binary Tree
类型:online_judge
Given a binary tree, write a function to return the diameter of the tree. The diameter is the length of the longest path between any two nodes in the tree.
Input
The root node of a binary tree.
Output
An integer representing the diameter of the tree.
Notes
The number of nodes in the tree is in the range [1, 10^4].
Each node's value is unique and within the range [-1000, 1000].
The tree may be unbalanced or a complete tree.