文章目录
- 😊1.题目
- 😉2.解法
😊1.题目
尝试一下该题
😉2.解法
/*** 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);
}