1
class Solution {
2
public boolean isSymmetric(TreeNode root) {
3
return isSymmetric(root.left, root.right);
4
}
5

6
public boolean isSymmetric(TreeNode rootLeft, TreeNode rootRight) {
7
if (rootLeft == null && rootRight == null) {
8
return true;
9
}
10
if (rootLeft == null || rootRight == null) {
11
return false;
12
}
13
if (rootLeft.val != rootRight.val) {
14
return false;
15
} else
16
return isSymmetric(rootLeft.right, rootRight.left)
17
&& isSymmetric(rootLeft.left, rootRight.right);
18
}
19
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0