Regular Expression Matching (leet code)

class Solution:
def isMatch(self, s: str, p: str) -> bool:
sr = [False for i in range(len§)]
strg = [sr for i in range(len(s))]

    def match(cr, cc):
        nonlocal s
        nonlocal p

        if cc == len(p):
            return cr == len(s)

        if strg[cr][cc] is True:
            return False
        first_match = cr < len(s) and (s[cr] == p[cc] or p[cc] == '.')
        if cr < len(s):
            strg[cr][cc] = True
        if len(p) - cc >= 2 and p[cc + 1] == '*':
            my_check = match(cr, cc + 2) or (first_match and match(cr + 1, cc))
            return my_check
        else:
            if first_match is False:
                return False
            return match(cr + 1, cc + 1)

    return match(0, 0)

s = Solution()

print(s.isMatch(‘aaa’, ‘a*’))

code not working and i have tried it 100 times

Hello Akshay, can you pls help me out with your logic. What are you trying to do ?
Thanks :slight_smile:
Happy Coding !!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.