/
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode left;
* struct TreeNode right;
* };
*/
bool isSame(struct TreeNode pRoot1, struct TreeNode pRoot2){
if(pRoot2 == NULL) return true;
if(pRoot2 != NULL && pRoot1 == NULL) return false;
if(pRoot1->val != pRoot2->val)return false;
return isSame(pRoot1->left,pRoot2->left) && isSame(pRoot1->right,pRoot2->right);
}
bool hasSubtree(struct TreeNode pRoot1, struct TreeNode pRoot2) {
if(pRoot2 == NULL) return false;
if(pRoot2 != NULL && pRoot1 == NULL) return false;
if(pRoot1->val == pRoot2->val)
if(isSame(pRoot1->left,pRoot2->left) && isSame(pRoot1->right,pRoot2->right))
return true;
return hasSubtree(pRoot1->left,pRoot2) || hasSubtree(pRoot1->right,pRoot2);
}