题解 | #对称的二叉树#
对称的二叉树
http://www.nowcoder.com/practice/ff05d44dfdb04e1d83bdbdab320efbcb
#include <stdbool.h>
typedef struct TreeNode Node;
int Check(Node* left, Node* right)
{
if (left == NULL && right != NULL)
return 0;
if (left != NULL && right == NULL)
return 0;
if (left == NULL && right == NULL)
return 1;
if (left->val == right->val)
return (Check(left->left, right->right)&&Check(left->right, right->left));
else
return 0;
}
bool isSymmetrical(struct TreeNode* pRoot ) {
if (pRoot == NULL)
return 1;
return Check(pRoot->left, pRoot->right);
}