mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-12 05:20:59 +08:00
Update 0236.二叉树的最近公共祖先.md
0236.二叉树的最近公共祖先 java版本中有一个变量没用,删除该变量
This commit is contained in:
@ -249,7 +249,6 @@ class Solution {
|
|||||||
```java
|
```java
|
||||||
// 代码精简版
|
// 代码精简版
|
||||||
class Solution {
|
class Solution {
|
||||||
TreeNode pre;
|
|
||||||
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
|
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
|
||||||
if (root == null || root.val == p.val ||root.val == q.val) return root;
|
if (root == null || root.val == p.val ||root.val == q.val) return root;
|
||||||
TreeNode left = lowestCommonAncestor(root.left,p,q);
|
TreeNode left = lowestCommonAncestor(root.left,p,q);
|
||||||
|
Reference in New Issue
Block a user