Update Leetcode 题解 - 树.md

补充最近公共祖先的时间与空间复杂度。
This commit is contained in:
CyC2018
2026-10-31 00:23:18 +08:00
parent 03d473bb79
commit 59ece82ab2
+2
View File
@@ -906,6 +906,8 @@ public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
}
```
每个节点最多访问一次,时间复杂度 O(N);递归深度最多为树的高度 H,空间复杂度 O(H),树退化成链时最坏为 O(N)。
### 6. 从有序数组中构造二叉查找树
108\. Convert Sorted Array to Binary Search Tree (Easy)