/*
public class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;

    public TreeNode(int val) {
        this.val = val;

    }

}
*/
public class Solution {
    public boolean isSymmetrical(TreeNode pRoot) {
        TreeNode lp=pRoot;
        TreeNode rp=pRoot;
        return contains(lp,rp);
        
        
    }
    public boolean contains(TreeNode lp,TreeNode rp){
        if(lp==null&&rp==null){
            return true;
        }
        if(lp==null||rp==null){
            return false;
        }
        if(lp.val!=rp.val){
            return false;
        }
        boolean flag1=contains(lp.left,rp.right);
        if(!flag1){
            return false;
        }
        boolean flag2=contains(lp.right,rp.left);
        if(!flag2){
            return false;
        }
        return true;
    }
}