```
bool isSubtree(TreeNode* s, TreeNode* t) {
if(s == NULL && s == t)
return true;
if((!s && t) || (s && !t))
return false;
//cout<<s->val<<" "<<t->val<<endl;
if(s->val == t->val && (s->left != NULL ? s->left->val:0) == (t->left != NULL ? t->left->val:0))
if(isSubtree(s->left,t->left)&&isSubtree(s->right,t->right))
return true;
return isSubtree(s->left,t)||isSubtree(s->right,t);
}
```