upd
This commit is contained in:
26
algorithms/labs/lab7/leetcode/1/solution.py
Normal file
26
algorithms/labs/lab7/leetcode/1/solution.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from typing import List
|
||||
|
||||
|
||||
class Solution:
|
||||
def isMatch(self, s: str, p: str) -> bool:
|
||||
i = j = 0
|
||||
star = -1
|
||||
match = 0
|
||||
n, m = len(s), len(p)
|
||||
while i < n:
|
||||
if j < m and (p[j] == s[i] or p[j] == "?"):
|
||||
i += 1
|
||||
j += 1
|
||||
elif j < m and p[j] == "*":
|
||||
star = j
|
||||
match = i
|
||||
j += 1
|
||||
elif star != -1:
|
||||
j = star + 1
|
||||
match += 1
|
||||
i = match
|
||||
else:
|
||||
return False
|
||||
while j < m and p[j] == "*":
|
||||
j += 1
|
||||
return j == m
|
||||
Reference in New Issue
Block a user