Wildcard Pattern Matching
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
CodingNinjas
author
2y
I solved this question using the dynamic programming approach.
CodingNinjas
author
2y
Brute Force
We will try to explore all the possibilities using the recursion.
Let’s say we have a recursive function ‘REC’ who has two arguments IDX and IDY where IDX represents the index in the text s...read more
CodingNinjas
author
2y
Memoization
Let’s say we have a recursive function ‘REC’ who has two arguments IDX and IDY where IDX represents the index in the text string and IDY represents the index in pattern string and its retur...read more
CodingNinjas
author
2y
Iterative DP
Let’s define DP[i][j] as DP[i][j is true if first i characters in given text matches the first j characters of pattern.
Create a N*M dimensional array DP where N is the size of the text and...read more
Add answer anonymously...
Top Adobe Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app