Merge pull request #113 from Joshua-Lu/patch-17

更新 0236.二叉树的最近公共祖先 Java版本
This commit is contained in:
Carl Sun
2021-05-14 11:02:43 +08:00
committed by GitHub

View File

@ -223,12 +223,10 @@ public:
Java
```Java
class Solution {
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
return lowestCommonAncestor1(root, p, q);
}
public TreeNode lowestCommonAncestor1(TreeNode root, TreeNode p, TreeNode q) {
if (root == null || root == p || root == q) {
@ -247,6 +245,7 @@ class Solution {
}
```
```java
// 代码精简版
class Solution {
@ -261,6 +260,7 @@ class Solution {
else return null;
}
}
```
Python