import numpy as np


def isMatch(s: str, p: str) -> bool:
    if p=='':
        return True if s=='' else False
    dp = np.zeros((len(s) + 1, len(p) + 1))
    dp[0][0] = 1
    flag = p[0] == '*'
    for i in range(1, len(p) + 1):
        if flag and p[i-1] == '*':
            dp[0][i] = 1
        else:
            break

    for i in range(1, len(s) + 1):
        for j in range(1, len(p) + 1):
            if dp[i - 1][j - 1] and (s[i - 1] == p[j - 1] or p[j - 1] in {'*', '?'}):
                dp[i][j] = 1
            elif dp[i][j - 1] and (p[j - 1] == '*'):
                dp[i][j] = 1
            elif dp[i - 1][j] and p[j - 1] == '*':
                dp[i][j] = 1
    if dp[len(s)][len(p)] == 1:
        return True
    else:
        return False


if __name__ == "__main__":
    print(isMatch('', '*'))
