正则表达式匹配
class Solution:
def isMatch(self, s: str, p: str) -> bool:
m, n = len(s), len(p)
dp = [[False for j in range(n + 1)] for i in range(m + 1)]
dp[0][0] = True
def match(i, j):
if i == 0: return False
if p[j - 1] == '.':
return True
return s[i - 1] == p[j - 1]
for i in range(m + 1):
for j in range(1, n + 1):
if p[j - 1] == '*':
if match
正则表达式匹配最先出现在Python成神之路。
共有 0 条评论