/*
public class TreeNode {
int val = 0;
TreeNode left = null;
TreeNode right = null;
public TreeNode(int val) {
this.val = val;
}
}
*/
public class Solution {
boolean isSymmetrical(TreeNode pRoot) {
if(pRoot == null) {
return true;
}
return isSymmetrical(pRoot.left, pRoot.right);
}
boolean isSymmetrical(TreeNode l, TreeNode r) {
if(l == null) {
return r == null;
}
if(r == null) {
return l == null;
}
return l.val == r.val &&
isSymmetrical(l.left, r.right) &&
isSymmetrical(l.right, r.left);
}
}