递归
class Solution{
public:
bool isSymmetric(TreeNode* root) {
if(!root) return true;
return m(root->left,root->right);
}
bool m(TreeNode*r1,TreeNode*r2)
{
bool x,y;
if(r1==nullptr)
{
if(r2==nullptr)return true;
return false;
}
else if(r1!=nullptr)
{
if(r2==nullptr)return false;
if(r1->val!=r2->val)return false;
x=m(r1->left,r2->right);
y=m(r1->right,r2->left);
}
return x&&y;
}
};
278

被折叠的 条评论
为什么被折叠?



