# Why my code has different result of same case while using "submit" and "run code"?

• ``````class Solution {
public:
bool isMatch(string s, string p) {
bool ** M = new bool*[s.length() + 1];
for (int i = 0; i < s.length() + 1; i++) {
M[i] = new bool[p.length() + 1];
}
M[0][0] = true;
for (int i = 0; i < p.length(); i++) {
if (p[i] == '*') {
M[0][i + 1] = M[0][i - 1];
}
}

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

``````

My code has different result of same case while using "submit" and "run code".
The case is
"cacabbabaaabccb"
"abb.a.*.b"

When I try to submit, this case'result always be true and it should be false, however, when I try to run the case by itself, the output is true. I am so confused. Is there anybody can help me with this? Thank you!

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.