Wildcard Matching

Given a string str and a pattern pat, return whether pat matches the entire str. In pat, '?' matches exactly one Unicode scalar and '*' matches any sequence…

Given a string str and a pattern pat, return whether pat matches the entire str. In pat, '?' matches exactly one Unicode scalar and '*' matches any sequence of scalars, including the empty sequence. Every other pattern scalar is literal. Metacharacters occurring in str are ordinary input data. This is whole-string matching, not substring search or regular-expression syntax; there is no escape syntax. Characters are Unicode scalar values, not UTF-8 bytes, UTF-16 code units or visual grapheme clusters. Combining marks count separately. Do not normalize, case-fold, trim or ignore any scalar. Unpaired surrogates are outside the input domain.

- 0 <= scalar length of each operand <= 200. - All Unicode scalar values are allowed; no unpaired surrogates. - The visualizer accepts each operand up to 8 scalars; longer valid inputs are coding-only.

Example 1: input str = "xaylmz", pat = "x?y*z"; output true. The question mark consumes a, the star consumes lm, and every remaining literal matches.

Example 2: input str = "xyza", pat = "x*z"; output false. The trailing a remains unmatched; matching only the prefix xyz is insufficient.

Example 3: input str = "a**", pat = "a??*"; output true. The two question marks consume the two ordinary text stars; the final pattern star consumes nothing.

Category: Strings. Topic: dynamic-programming. Difficulty: hard. Patterns: dynamic-programming.