This commit is contained in:
nik
2025-10-01 22:55:09 +03:00
parent 4d0ece634b
commit 74e98c37c4
591 changed files with 20286 additions and 0 deletions

View File

@@ -0,0 +1 @@
https://leetcode.com/problems/wildcard-matching/?envType=problem-list-v2&envId=greedy

View 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