O(n)
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
bool mirror(struct TreeNode* left,struct TreeNode* right){
if(left==NULL&&right==NULL){
return true;
}
if(right==NULL||left==NULL){
return false;
}
return left->val==right->val&&mirror(left->left,right->right)&&mirror(left->right,right->left);
}
bool isSymmetric(struct TreeNode* root){
if(root==NULL){
return true;
}
return mirror(root->left,root->right);
}