修复bug
This commit is contained in:
parent
0d822fc959
commit
c4dba758da
|
@ -42,10 +42,10 @@ impl Solution {
|
|||
/// * 👍 1603
|
||||
/// * 👎 0
|
||||
pub fn is_symmetric(root: Option<Rc<RefCell<TreeNode>>>) -> bool {
|
||||
fn symmetric(t1: &Option<Rc<RefCell<TreeNode>>>, t2: &Option<Rc<RefCell<TreeNode>>>) -> bool {
|
||||
fn check(t1: &Option<Rc<RefCell<TreeNode>>>, t2: &Option<Rc<RefCell<TreeNode>>>) -> bool {
|
||||
match (t1, t2) {
|
||||
(None, None) => true,
|
||||
(Some(n1), Some(n2)) => n1.borrow().val == n2.borrow().val && symmetric(&n1.borrow().left, &n2.borrow().right) && symmetric(&n1.borrow().right, &n2.borrow().left),
|
||||
(Some(n1), Some(n2)) => n1.borrow().val == n2.borrow().val && check(&n1.borrow().left, &n2.borrow().right) && check(&n1.borrow().right, &n2.borrow().left),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue