change leetcode contetn

This commit is contained in:
gameloader 2024-02-27 11:21:38 +08:00
parent 5a44b40b64
commit 741f4f63b1

View File

@ -17,6 +17,8 @@ The diameter of a binary tree is the length of the longest path between any two
The length of a path between two nodes is represented by the number of edges between them.
![0227W27EaKxHpjd2](https://testingcf.jsdelivr.net/gh/game-loader/picbase@master/uPic/0227W27EaKxHpjd2.png)
### 题解
读题, 题目要求寻找二叉树中任意两节点之间的最大距离. 这时这个二叉树更像是一个图的性质而不是树, 即寻找图中任意两节点直接的最大距离. 考虑任意一点到另一点的距离等于其到另一点的父节点的距离减一, 则使用一个二维数组保存每个节点的两个属性: