Skip to content

Commit 122a5eb

Browse files
committed
update readme
1 parent 0dc89b6 commit 122a5eb

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ Success is like pregnancy, Everybody congratulates you but nobody knows how many
7272
|100|[Same Tree](https://leetcode.com/problems/same-tree/)| [Python [Yu]](./tree/Yu/100_isSameTree.py) <br> [Python [Sheng]](./tree/YeSheng/100.Same_Tree.py) | _O(N)_| _O(1)_ | Easy ||[EAFP vs. LBYL](https://github.com/ictar/python-doc/blob/master/Others/%E5%AE%9E%E7%94%A8Python%EF%BC%9AEAFP%20VS.%20LBYL.md)|
7373
|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree/#/description)| [Python [Yu]](./tree/Yu/101_symmetricTree.py) <br> [Python [Sheng]](./tree/YeSheng/101.Symmetric_Tree.py) | _O(N)_| _O(1)_ | Easy ||[Editorial Solution](https://leetcode.com/articles/symmetric-tree/)|
7474
|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree/#/description)| [Python [Yu]](https://github.com/yuzhoujr/LeetCode/blob/master/tree/Yu/111_minDepth.py) <br> [Python [Sheng]](https://github.com/yuzhoujr/LeetCode/blob/master/tree/YeSheng/111.Minimum_Depth_of_Binary_Tree.py) | _O(N)_| _O(1)_ | Easy |||
75-
|104|[Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/)| [Python](./tree/Yu/104_maxDepth.py) | _O(1)_| _O(n)_ | Easy | ||
76-
|235|[Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/#/description)| [Python](./tree/Yu/235_lca_bst.py) | _O(1)_| _O(n)_ | Easy | ||
75+
|104|[Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/)| [Python](./tree/Yu/104_maxDepth.py) | _O(N)_| _O(1)_ | Easy | ||
76+
|235|[Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/#/description)| [Python](./tree/Yu/235_lca_bst.py) | _O(N)_| _O(1)_ | Easy | ||

tree/Yu/235_lca_bst.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,28 @@
55

66
# ****************
77
# Descrption:
8-
# Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.
8+
9+
# Time: O(n)
10+
# Space: O(1)
11+
#
12+
# Given a binary search tree (BST), find the lowest common ancestor (LCA)
13+
# of two given nodes in the BST.
14+
#
15+
# According to the definition of LCA on Wikipedia: “The lowest common ancestor
16+
# is defined between two nodes v and w as the lowest node in T that has both v
17+
# and w as descendants (where we allow a node to be a descendant of itself).”
18+
#
19+
# _______6______
20+
# / \
21+
# ___2__ ___8__
22+
# / \ / \
23+
# 0 _4 7 9
24+
# / \
25+
# 3 5
26+
# For example, the lowest common ancestor (LCA) of nodes 2 and 8 is 6.
27+
# Another example is LCA of nodes 2 and 4 is 2, since a node can be a
28+
# descendant of itself according to the LCA definition.
29+
930
# ****************
1031

1132
# 思路:

0 commit comments

Comments
 (0)