Very easy C++ Solution by changing Tree A


#1

void merge(TreeNode** A, TreeNode* B)
{
if((*A) == NULL and B== NULL)
return ;

if((*A) == NULL and B != NULL)
{
(*A) = B;
return;
}

if(B == NULL)
return ;

(*A)->val += B->val;
merge(&(*A)->left, B->left);
merge(&(*A)->right, B->right);

}
TreeNode* Solution::solve(TreeNode* A, TreeNode* B)
{
merge(&A,B);
return A;
}