Do upvote , It gives support to post much more like that !!
It also indicate that my code really helped you Thank you!!
class Solution {
public:
bool ismirror(TreeNode * p,TreeNode * q){
if(p == NULL && q == NULL){
return true;
}
if(p == NULL && q != NULL || p!= NULL && q == NULL){
return false;
}
return p->val == q->val && ismirror(p->left ,q->right) && ismirror(p->right ,q->left) ? true : false;
}
bool isSymmetric(TreeNode* p) {
if(p == NULL){
return true;
}
if(p->left == NULL && p->right == NULL){
return true;
}
if(p->left == NULL && p->right != NULL || p->left != NULL && p->right == NULL ){
return false;
}
bool ltree = ismirror(p->left , p->right);
return (ltree) ? true : false;
}
};Do upvote , It gives support to post much more like that !!
It also indicate that my code really helped you Thank you!!