/**
* 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&&!q) return true;
if(!p&&q ||p&&!q) return false;
if(q->val!=p->val) return false;
return isSameTree(p->left,q->left)&&isSameTree(p->right,q->right);
}
结果:
标签:right,return,struct,相同,val,&&,TreeNode,100 From: https://www.cnblogs.com/llllmz/p/18054183