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.
Note: The length of path between two nodes is represented by the number of edges between them.
給予一個二元樹,你需要計算出樹的直徑。一個樹的直徑是在該樹中任意兩個節點的最遠距離。這條路徑可能不會經過樹根。
提示:兩個節點中的路徑長度代表他們之間存在幾條邊。
NULL
才停止(回傳0
)。LeetCode
C++