Compiler is giving wrong output


#1

This is accepted submission but according to the code for A = “” B = “.?” should return 1
but it is returning 0. whereas on leetcode same code giving me output as 1
please correct it. if m wrong

int Solution::isMatch(const string s, const string p) {
vector<vector>dp(s.length()+1,vector(p.length()+1,false));
dp[0][0] = true;
for(int i = 1;i<=p.length();i++)if(i>1&&p[i-1]==’*’){
dp[0][i] = dp[0][i-2];
}

    for(int i = 1;i<=s.length();i++){
        for(int j=1;j<=p.length();j++){
            if(s[i-1]==p[j-1]||p[j-1]=='.')dp[i][j] = dp[i-1][j-1];
            else if(j>1&&p[j-1]=='*'){
                if(p[j-2]==s[i-1]||p[j-2]=='.')
                    dp[i][j] = (dp[i-1][j-2]|dp[i-1][j]|dp[i][j-2]);
                else dp[i][j] = dp[i][j-2];
            }
        }
    }
    return dp[s.length()][p.length()];

}