Recursion with memonisation


#1

// Recursive approach using memonisation
bool help(string a,string b,string c,int d,int e)
{if(e>=b.size()&&d>=a.size())
return c=="";
if(e>=b.size())
return c==a.substr(d);
if(d>=a.size())
return c==b.substr(e);
if(a[d]==b[e]&&a[d]==c[0])
return help(a,b,c.substr(1),d+1,e)||help(a,b,c.substr(1),d,e+1);
else if(a[d]==c[0])
return help(a,b,c.substr(1),d+1,e);
else if()

}
int Solution::isInterleave(string A, string B, string C) {
return help(A,B,C,0,0);
}
.