Created
June 3, 2021 18:44
-
-
Save lovesegfault/ba999e25e2a7bbd58119eb15c64bf1a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Solution; | |
#[derive(Debug, PartialEq, Eq)] | |
pub struct TreeNode { | |
pub val: i32, | |
pub left: Option<Rc<RefCell<TreeNode>>>, | |
pub right: Option<Rc<RefCell<TreeNode>>>, | |
} | |
impl TreeNode { | |
#[inline] | |
pub fn new(val: i32) -> Self { | |
TreeNode { | |
val, | |
left: None, | |
right: None, | |
} | |
} | |
} | |
use std::borrow::Borrow; | |
use std::cell::RefCell; | |
use std::rc::Rc; | |
impl Solution { | |
pub fn lowest_common_ancestor( | |
root: Option<Rc<RefCell<TreeNode>>>, | |
p: Option<Rc<RefCell<TreeNode>>>, | |
q: Option<Rc<RefCell<TreeNode>>>, | |
) -> Option<Rc<RefCell<TreeNode>>> { | |
let p_val: i32 = p.as_ref().map(|r| r.borrow().val)?; | |
todo!() | |
} | |
} | |
fn main() { | |
println!("Hello, world!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment