class Solution {
public:
    bool helper(TreeNode*p,TreeNode*q){
        if(p==NULL)return(q==NULL);
        if(q==NULL)return false;
        
        if(p->val!=q->val)return false;
        return helper(p->right,q->left)&&helper(p->left,q->right);
    }
    bool isSymmetrical(TreeNode* pRoot) {
        if(pRoot==NULL)return true;
        return helper(pRoot->left,pRoot->right);
    }

};