mirror of
https://github.com/CyC2018/CS-Notes.git
synced 2025-07-10 13:37:35 +08:00
auto commit
This commit is contained in:
@ -2590,7 +2590,7 @@ public int StrToInt(String str) {
|
|||||||
/ \
|
/ \
|
||||||
___2__ ___8__
|
___2__ ___8__
|
||||||
/ \ / \
|
/ \ / \
|
||||||
0 _4 7 9
|
0 4 7 9
|
||||||
/ \
|
/ \
|
||||||
3 5
|
3 5
|
||||||
For example, the lowest common ancestor (LCA) of nodes 2 and 8 is 6. Another example is LCA of nodes 2 and 4 is 2, since a node can be a descendant of itself according to the LCA definition.
|
For example, the lowest common ancestor (LCA) of nodes 2 and 8 is 6. Another example is LCA of nodes 2 and 4 is 2, since a node can be a descendant of itself according to the LCA definition.
|
||||||
@ -2611,7 +2611,7 @@ public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
|
|||||||
/ \
|
/ \
|
||||||
___5__ ___1__
|
___5__ ___1__
|
||||||
/ \ / \
|
/ \ / \
|
||||||
6 _2 0 8
|
6 2 0 8
|
||||||
/ \
|
/ \
|
||||||
7 4
|
7 4
|
||||||
For example, the lowest common ancestor (LCA) of nodes 5 and 1 is 3. Another example is LCA of nodes 5 and 4 is 5, since a node can be a descendant of itself according to the LCA definition.
|
For example, the lowest common ancestor (LCA) of nodes 5 and 1 is 3. Another example is LCA of nodes 5 and 4 is 5, since a node can be a descendant of itself according to the LCA definition.
|
||||||
|
Reference in New Issue
Block a user