We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 96c50c3 commit df60970Copy full SHA for df60970
lowest-common-ancestor-of-a-binary-search-tree/hyer0705.ts
@@ -11,8 +11,8 @@
11
* }
12
13
*
14
- * Time Complexity: O(h) where h is the height of the tree
15
- * Space Complexity: O(1)
+ * Time Complexity: O(logn) in average, O(n) in the worst case
+ * Space Complexity: O(logn) in average, O(n) in the worst case
16
*/
17
function lowestCommonAncestor(root: TreeNode | null, p: TreeNode | null, q: TreeNode | null): TreeNode | null {
18
if (p.val < root.val && q.val < root.val) {
0 commit comments