Problem title
Difficulty
Avg time to solve

PAINT THE FENCE
Easy
20 mins
Reverse Words In A String
Easy
10 mins
Wildcard Pattern Matching
Hard
50 mins
Move Zeroes To End
Moderate
30 mins
Intersection of Two Linked Lists
Easy
25 mins
Boundary Traversal of Binary Tree
Hard
20 mins
Painter's Partition Problem
Moderate
25 mins
Majority element
Easy
15 mins
Merge Intervals
Moderate
20 mins
Sum Of Two Arrays
Easy
15 mins
77

Wildcard Pattern Matching

Difficulty: HARD
Contributed By
Avg. time to solve
50 min
Success Rate
30%

Problem Statement

Given a text and a wildcard pattern of size N and M respectively, implement a wildcard pattern matching algorithm that finds if the wildcard pattern is matched with the text. The matching should cover the entire text not partial text.

The wildcard pattern can include the characters ‘?’ and ‘*’

 ‘?’ – matches any single character 
 ‘*’ – Matches any sequence of characters(sequence can be of length 0 or more)
Input Format:
The first line contains an Integer 'T' which denotes the number of test cases/queries to be run. 
Then the test cases follow. 

The first line of input for each test case/query contains a string representing the wildcard pattern.

The second line of input for each test case/query contains a string representing the text.
Output Format:
For each test case, print ‘True’ if the text matches the pattern, print ‘False’ otherwise(without quotes).

Output for every test case will be printed in a separate line.
Note:
You do not need to print anything, it has already been taken care of. Just implement the function.
Constraints:
1 <= T <= 100
1 <= N <= 200
1 <= M <= 200

Where 'N' denotes the length of 'TEXT' and 'M' denotes the length of 'PATTERN'.

'TEXT' and 'PATTERN' contain only lowercase letters and patterns may contain special characters ‘*’ and ‘?’

Time Limit: 1sec
Sample Input 1:
3
?ay
ray
ab*cd
abdefcd
ab?d
abcc
Sample Output 1:
True
True
False
Explanation of the Sample Input1:
Test Case 1:
The pattern is “?ay” and the text is ray.
‘?’ can match a character so it matches with a character ‘r’ of the text and rest of the text matches with the pattern so we print True.

Test Case 2:
“ab” of text matches with “ab” of pattern and then ‘*’ of pattern matches with “def” of the text and “cd” of text matches with “cd” of the pattern. Whole text matches with the pattern so we print True.

Test Case 3:
“ab” of pattern matches with “ab” of text. ‘?’ of pattern matches with ‘c’ of the text but ‘d’ of the pattern do not match with ‘c’ of the text so we print False.
Sample Input 1:
1
ba*a?
baaabab
Sample Output 1:
True
Reset Code
Full screen
copy-code
Console