From 59ece82ab29eb9479d2b2e7ab026bcddc8d8864a Mon Sep 17 00:00:00 2001 From: CyC2018 Date: Sat, 31 Oct 2026 00:23:18 +0800 Subject: [PATCH] =?UTF-8?q?Update=20Leetcode=20=E9=A2=98=E8=A7=A3=20-=20?= =?UTF-8?q?=E6=A0=91.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 补充最近公共祖先的时间与空间复杂度。 --- notes/Leetcode 题解 - 树.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/notes/Leetcode 题解 - 树.md b/notes/Leetcode 题解 - 树.md index 014a4607..8c7a6733 100644 --- a/notes/Leetcode 题解 - 树.md +++ b/notes/Leetcode 题解 - 树.md @@ -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)