Skip to content

Commit 31f7a06

Browse files
committed
fix: ts solution format
面试题68 - I. 二叉搜索树的最近公共祖先
1 parent a3f88e3 commit 31f7a06

File tree

1 file changed

+10
-6
lines changed
  • lcof/面试题68 - I. 二叉搜索树的最近公共祖先

1 file changed

+10
-6
lines changed

lcof/面试题68 - I. 二叉搜索树的最近公共祖先/README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,22 @@ var lowestCommonAncestor = function (root, p, q) {
171171
* }
172172
* }
173173
*/
174-
function lowestCommonAncestor(root: TreeNode | null, p: TreeNode | null, q: TreeNode | null): TreeNode | null {
174+
function lowestCommonAncestor(
175+
root: TreeNode | null,
176+
p: TreeNode | null,
177+
q: TreeNode | null,
178+
): TreeNode | null {
175179
if (root == null) {
176-
return root
180+
return root;
177181
}
178182
if (root.val > p.val && root.val > q.val) {
179-
return lowestCommonAncestor(root.left, p, q)
183+
return lowestCommonAncestor(root.left, p, q);
180184
}
181185
if (root.val < p.val && root.val < q.val) {
182-
return lowestCommonAncestor(root.right, p, q)
186+
return lowestCommonAncestor(root.right, p, q);
183187
}
184-
return root
185-
};
188+
return root;
189+
}
186190
```
187191

188192
循环:

0 commit comments

Comments
 (0)