πŸ’‘ Wildcard Pattern Matching problem

i am unable to find a suitable approach pls help
like i know what to do when i get same characters or a ? in pattern but i dont know how to deal with * char and what the base cases will be

Text = β€œbaaabab”,
Pattern = β€œbaab", output : true
Pattern = β€œbaaa?ab”, output : true
Pattern = β€œbaa?", output : true
Pattern = "a
ab”, output : false

Each occurrence of β€˜?’ character in wildcard pattern can be replaced with any other character and each occurrence of β€˜*’ with a sequence of characters such that the wildcard pattern becomes identical to the input string after replacement.

Let’s consider any character in the pattern.

Case 1: The character is β€˜*’
Here two cases arise

We can ignore β€˜β€™ character and move to next character in the Pattern.
β€˜
’ character matches with one or more characters in Text. Here we will move to next character in the string.
Case 2: The character is β€˜?’
We can ignore current character in Text and move to next character in the Pattern and Text.

Case 3: The character is not a wildcard character
If current character in Text matches with current character in Pattern, we move to next character in the Pattern and Text. If they do not match, wildcard pattern and Text do not match.


@Saurabh2 , same approach i have implemented recursively.