go实现
/** * * @param s string字符串 * @param p string字符串 * @return bool布尔型 */ func isMatch( s string , p string ) bool { // write code here row := len(s) col := len(p) if col == 0 { if row == 0 { return true } return false } dp := make([][]bool, row+1) for i:=0; i< len(dp); i++{ dp[i] = make([]bool, col+1) } dp[0][0] = true for i:=1; i< len(dp[0]); i++{ if p[i-1] == '*' { dp[0][i] = true }else{ break } } for i:=1; i<=row; i++{ for j:=1; j<=col; j++{ if p[j-1] == '*' { dp[i][j] = dp[i-1][j] || dp[i][j-1] }else if p[j-1] == '?' || s[i-1] == p[j-1] { dp[i][j] = dp[i-1][j-1] } } } return dp[row][col] }