mirror of
https://gitlab.com/game-loader/hugo.git
synced 2025-04-20 14:02:07 +08:00
leetcode post
This commit is contained in:
parent
741f4f63b1
commit
d2019dad9f
@ -21,7 +21,7 @@ The length of a path between two nodes is represented by the number of edges bet
|
|||||||
|
|
||||||
### 题解
|
### 题解
|
||||||
|
|
||||||
读题, 题目要求寻找二叉树中任意两节点之间的最大距离. 这时这个二叉树更像是一个图的性质而不是树, 即寻找图中任意两节点直接的最大距离. 考虑任意一点到另一点的距离等于其到另一点的父节点的距离减一, 则使用一个二维数组保存每个节点的两个属性:
|
读题, 题目要求寻找二叉树中任意两节点之间的最大距离. 这时这个二叉树更像是一个图的性质而不是树, 即寻找图中任意两节点之间的最大距离. 考虑任意一点到另一点的距离等于其到另一点的父节点的距离减一, 则使用一个二维数组保存每个节点的两个属性:
|
||||||
|
|
||||||
1. 以该节点为根节点且经过该节点的最大直径
|
1. 以该节点为根节点且经过该节点的最大直径
|
||||||
2. 以该节点为根节点的子树中叶子节点到该节点的最大距离
|
2. 以该节点为根节点的子树中叶子节点到该节点的最大距离
|
||||||
|
Loading…
Reference in New Issue
Block a user