Python || faster than 90% || Explained with comments
Complexity\n- Time complexity:\nBetter than 90%\n\n- Space complexity:\nBetter than 90%\n\n# Code\n\nclass Solution:\n    def isMatch(self, s: str, p: str) -> b
# Complexity\n- Time complexity:\nBetter than 90%\n\n- Space complexity:\nBetter than 90%\n\n# Code\n```\nclass Solution:\n    def isMatch(self, s: str, p: str) -> bool:\n        # Initialize the pointers for the input string and the pattern\n        i = 0\n        j = 0\n    \n        # Initialize the pointers for the last character matched and the last\n        # \'*\' encountered in the pattern\n        last_match = 0\n        star = -1\n    \n        # Loop through the input string and the pattern\n        while i < len(s):\n            # Check if the current characters in the input string and the pattern\n            # match, or if the pattern character is a \'?\'\n            if j < len(p) and (s[i] == p[j] or p[j] == \'?\'):\n                # Move the pointers for the input string and the pattern forward\n                i += 1\n                j += 1\n            # Check if the current pattern character is a \'*\'\n            elif j < len(p) and p[j] == \'*\':\n                # Store the current positions of the pointers for the input string\n                # and the pattern\n                last_match = i\n                star = j\n                # Move the pointer for the pattern forward\n                j += 1\n            # If none of the above conditions are met, check if we have encountered\n            # a \'*\' in the pattern previously\n            elif star != -1:\n                # Move the pointer for the pattern back to the last \'*\'\n                j = star + 1\n                # Move the pointer for the input string to the next character\n                # after the last character matched\n                i = last_match + 1\n                # Move the pointer for the last character matched forward\n                last_match += 1\n            # If none of the above conditions are met, the input string and the\n            # pattern do not match\n            else:\n                return False\n    \n        # Loop through the remaining characters in the pattern and check if they\n        # are all \'*\' characters\n        while j < len(p) and p[j] == \'*\':\n            j += 1\n    \n        # Return True if all the characters in the pattern have been processed,\n        # False otherwise\n        return j == len(p)\n    \n```
['Python3']