Close
Topic list
Wildcard Pattern Matching
HARD
50 mins
Strings
Dynamic Programming
Topics (Covered in this problem)
Problem solved
Skill meter
Strings
-
-
Dynamic Programming
-
-
Other topics
Problem solved
Skill meter
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Wildcard Pattern Matching

Contributed by
Dhruv Sharma
Hard
0/120
Avg time to solve 50 mins
Success Rate 30 %
Share

## Problem Statement

#### 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)
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### 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
``````
Auto
Console