didn’t understand the given question
Wildcard pattern matching
hello @ajayrajsingh_817
Text = “baaabab”,
Pattern = “ ba ab", output : true
Pattern = “baaa?ab”, output : true
Pattern = “ba a?", 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.
rest all the cases are clear but the first case is not clear (*)
first case is exaclty same as lcs.
thats either we can match * with the character .
or we can ignore it
not passes all test cases
check ur base case,it is not correct
if(str[i]==’\0’) then u should return true only when ptr[j]==’\0’
or when all characters after j are *.
correct my base case in my code
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.
sir check my base condition first
bro test case r very strict,even after making changes it will not pass.
try bottom up with some space optimisation.
if u stuck ,then feel free to ping me back