题目链接:https://leetcode.cn/problems/dui-cheng-de-er-cha-shu-lcof/?favorite=xb9nqhhg
题目:
代码:
class Solution {
public:
bool check(TreeNode *p,TreeNode *q)
{
if(p==NULL&&q==NULL)
{
return true;
}
if((p==NULL || q==NULL )||(q->val!=p->val))
{
return false;
}
return check(p->left,q->right) && check(p->right,q->left);
}
bool isSymmetric(TreeNode* root) {
if(root == NULL)
return true;
int flag = check(root,root);
return flag;
}
};