C++ 代码
class Solution {
public:
bool isMatch(string s, string p) {
int n=s.length(),m=p.length();
bool f[310][310]={};
f[n][m]=1;
for(int i=n;i>=0;i--){
for(int j=m-1;j>=0;j--){
if(p[j+1]!='*'){
f[i][j]=(s[i]==p[j]||p[j]=='.')&&f[i+1][j+1];
}
else{
f[i][j]=f[i][j+2]||(s[i]==p[j]||p[j]=='.')&&f[i+1][j];
}
}
}
return f[0][0];
}
};