Wildcard Matching
Does pattern P match text T entirely? In P, ? matches any single character and * matches any (possibly empty) run of characters.
Input: the first line has T; the second line has P.
Output: YES if P matches all of T, else NO.
Constraints:
- 1 ≤ |T|, |P| ≤ 2000
- T is lowercase; P has lowercase, ? and *
Sample Tests
Input 1
abcd a*d
Output 1
YES
Input 2
ab a?c
Output 2
NO
Discussion (opens after you solve — no spoilers before)
No comments yet.