/*
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 root) {
if(root == null) return true;
return isSame(root.left,root.right);
}
boolean isSame(TreeNode p,TreeNode q){
if(p == null && q != null) return false;
if(p != null && q == null) return false;
if(p == null && q == null) return true;
if(p.val != q.val) return false;
return isSame(p.left,q.right) && isSame(p.right,q.left);
}
}