文章目录
😊1.题目
😉2.解法
c
/**
* 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;
else
return q->val ==p->val && isSameTree
(q->left,p->left) &&isSameTree(q->right,p->right);
}