class Solution {
public:
bool check(TreeNode* p, TreeNode* q){
if(p == NULL && q == NULL) return true;
if(p == NULL || q == NULL) return false;
return (p -> val == q -> val) && check(p -> left, q -> left) && check(q -> right, p -> right);
}
bool isSameTree(TreeNode* p, TreeNode* q) {
return check(p, q);
}
};
和之前的题很像,只用改一下就可以了


