parent
dc2edca6ab
commit
b5e3b801d3
|
|
@ -454,7 +454,11 @@ impl Solution {
|
||||||
p: Option<Rc<RefCell<TreeNode>>>,
|
p: Option<Rc<RefCell<TreeNode>>>,
|
||||||
q: Option<Rc<RefCell<TreeNode>>>,
|
q: Option<Rc<RefCell<TreeNode>>>,
|
||||||
) -> Option<Rc<RefCell<TreeNode>>> {
|
) -> Option<Rc<RefCell<TreeNode>>> {
|
||||||
if root == p || root == q || root.is_none() {
|
if root.is_none() {
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
if Rc::ptr_eq(root.as_ref().unwrap(), p.as_ref().unwrap())
|
||||||
|
|| Rc::ptr_eq(root.as_ref().unwrap(), q.as_ref().unwrap()) {
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
let left = Self::lowest_common_ancestor(
|
let left = Self::lowest_common_ancestor(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue