LeetCode第101题. 对称二叉树
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
bool isSameTree(struct TreeNode* p,struct TreeNode* q)
{
if(p == NULL || q == NULL)
return p == q;
return p->val == q->val && isSameTree(p->left,q->right) && isSameTree(q->left,p->right);
}
bool isSymmetric(struct TreeNode* root) {
return isSameTree(root->left,root->right);
}