bool check(TreeNode* left, TreeNode* right) {
if (!left && !right) return true;
if (!left || !right) return false;
return left->val == right->val &&
check(left->left, right->right) &&
check(left->right, right->left);
}
bool isSymmetric(TreeNode* root) {
// 注意这里检查根节点是否为空
return check(root, root);
}
标签:right,return,Offer,28,二叉树,&&,TreeNode,check,left
From: https://www.cnblogs.com/yaocy/p/17112761.html