Given a text 'str' and a wildcard pattern 'pattern', your task is to complete the function wildcard that returns '1' if the wildcard pattern is matched with text else returns '0'.The function takes two strings as arguments 'pattern' and 'str'.
The wildcard pattern can include the characters ‘?’ and ‘*’
‘?’ – matches any single character
‘*’ – Matches any sequence of characters (including the empty sequence)
Text = "baaabab", Pattern = “*****ba*****ab", output : true Pattern = "baaa?ab", output : true Pattern = "ba*a?", output : true Pattern = "a*ab", output : false
Note: The matching should cover the entire text (not partial text).
The first line of input will contain no of test cases T. Then T test cases follow. Each test case contains 2 lines. The first line of each test case represents a string pat denoting the pattern and the next line contains string str.
The output will be 1 if the string follows the pattern else it will be 0.
Complete the function wildCard() which takes the two strings 'pattern' and 'str' as input parameters and returns the answer.
Expected Time Complexity: O(N*M)
Expected Auxiliary Space: O(N*M)
1 <= T <= 50
1 <= length of(str,pat) <= 200
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.