class Solution(object):
def isMatched(self, s, p):
def dfs(s, si, p, pi):
while si < len(s) and pi < len(p) and s[si] == p[pi]:
si += 1
pi += 1
if si == len(s) and pi == len(p):
return True
if pi < len(p) and p[pi] == "{":
c = p[pi  1]
start = pi
while pi < len(p) and p[pi] != "}":
pi += 1
left, right = map(int, p[start+1:pi].split(","))
for k in range(left, right):
if s[si:si + k  1] == c * (k  1):
if dfs(s, si + k  1, p, pi + 1):
return True
return False
return dfs(s, 0, p, 0)
jedihy
@jedihy
355
Reputation
473
Posts
2278
Profile views
7
Followers
3
Following
Posts made by jedihy

RE: (Uber Phone interview) string pattern matching

RE: Uber find the largest kth element in a data stream
@ZhackerZ No, that won't work with stream.

RE: Group Anagrams
Is it required to provide Java solutions for these articles? This is the first time I have ever seen Python solution in an article.