Open FantasyJXF opened 5 years ago
bool hasSubtree(TreeNode *T1, TreeNode *T2) { if(T2==nullptr && T1==nullptr) return true; if (T1 != nullptr && T2!=nullptr && T1->val == T2->val) { return hasSubtree(T1->left,T2->left) && hasSubtree(T1->right,T2->right); } return false; }