Участник:F.Nikitin/IsMatch
Материал из DISCOPAL
class Solution: def isMatch(self, s, p): sl, pl = len(s), len(p) s_s, s_p = None, None s_i, p_i = 0, 0 while s_i < sl: if p_i < pl and (p[p_i] == "?" or s[s_i] == p[p_i]): s_i += 1 p_i += 1 elif p_i < pl and p[p_i] == "*": s_s, s_p = s_i,p_i p_i += 1 elif s_p is not None: s_i, p_i = s_s + 1, s_p else: return False while p_i < pl: if p[p_i] != "*": return False p_i += 1 return True