Glob Pattern Match
pattern is made of lowercase letters and the two wildcards ? and *. A ? stands for exactly one character and a * stands for any run of zero or more characters. Return true if pattern can match all of text from its first character to its last, and false otherwise. Both strings may be empty: an empty pattern matches only the empty text, and a pattern made only of * characters matches everything.
Example 1
text "cabinet"
pattern "c*n?t"
returns true
The * covers abi and the ? covers e.
Example 2
text "cabinet"
pattern "c*n?"
returns false
The pattern ends one character after the n, but the text still has et there.
Constraints
0 <= len(text) <= 30, lowercase letters only0 <= len(pattern) <= 30, lowercase letters,?and*only
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Dynamic programming problems
- Least Charge to CrossHard
- Patterns With Repeat MarksHard
- Shatter the CrystalsHard
- Two Pickers Down the FieldHard
- Two Towers of One HeightHard
- Factorials Up to nBeginner
- Fibonacci NumberBeginner
- Frog Across the StonesBeginner