Right output in custom test case but producing wrong output on submission .. Please help


#1

string a,b;
int dp[2005][2005];
bool fun(int posa,int posb){
if(posa==a.size()&&posb==b.size()){
return true;
}
if(posa<2005&&posb<2005&&dp[posa][posb]!=-1) return dp[posa][posb];
bool boo=false;
if(a[posa]==b[posb]) boo|=fun(posa+1,posb+1);
if(b[posb]==’.’) boo|=fun(posa+1,posb+1);
if(b[posb]!=’’&&b[posb+1]==’’){
char z=b[posb];
if(z==’.’){
boo|=fun(posa,posb+2);
for(int i=posa;i<a.length();i++){
boo|=fun(i+1,posb+2);
}
}
else{
boo|=fun(posa,posb+2);
for(int i=posa;i<a.length();i++){
if(a[i]==z){
boo|=fun(i+1,posb+2);
}
else break;
}
}

}
if(posa<2005&&posb<2005) dp[posa][posb]=boo;
return boo;

}
int Solution::isMatch(const string A, const string B) {

a=A;b=B;

memset(dp,-1,sizeof(dp));
return fun(0,0);

}