https://practice.geeksforgeeks.org/problems/check-if-subtree/1/

```
void inorder(Node *root, string &x)
{
if(root)
{
inorder(root->left,x);
x=x+to_string(root->data);
inorder(root->right,x);
}
}
void preorder(Node *root, string &y)
{
if(root)
{
y=y+to_string(root->data);
preorder(root->left,y);
preorder(root->right,y);
}
}
bool isSubTree(Node* T, Node* S)
{
if(S==NULL)
return true;
if(T==NULL)
return false;
string inmain, premain, insub, presub;
inorder(T,inmain);
preorder(T,premain);
inorder(S,insub);
preorder(S,presub);
if(inmain==insub&&premain==presub)
return true;
else if(inmain.find(insub)!=string::npos&&premain.find(presub)!=string::npos)
return true;
else
return false;
}
```

**One TC is failing and that is also not completely visible on the GFG platform.**

**I want to know whether the code is correct or not and if WRONG, where is the logic going wrong?**

*Logic: Just checking inorder and preorder of both trees and checking whether it is a subset or not!*

P.S. Please donâ€™t provide me GFG article links of the same question. This is my own approach and I want help regarding this only.