FunctionRacerProblemsRace

Glob Pattern Match

HardDynamic programmingPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Dynamic programming problems