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 63e5452 commit 8712becCopy full SHA for 8712bec
lowest-common-ancestor-of-a-binary-search-tree/gitsunmin.ts
@@ -15,11 +15,11 @@ class TreeNode {
15
}
16
17
18
-function lowestCommonAncestor(root: TreeNode | null, p: TreeNode, q: TreeNode): TreeNode | null {
+export function lowestCommonAncestor(root: TreeNode | null, p: TreeNode, q: TreeNode): TreeNode | null {
19
while (root) {
20
if (p.val < root.val && q.val < root.val) root = root.left;
21
else if (p.val > root.val && q.val > root.val) root = root.right;
22
else return root;
23
24
return null;
25
-};
+};
0 commit comments