Wildcard Matching (`*` and `?`)

Implement wildcard pattern matching with support for `?` (matches any single character) and `*` (matches any sequence of characters, including empty). Given *s* and pattern *p*, determine if the pattern matches the **entire** string *s*. Return `true` or `false`.

Input Format

Two lines: string s, then pattern p.

Output Format

Output "true" or "false".

Constraints

  • 0 <= len(s), len(p) <= 1000.

Examples

Example 1:

Input:

s = "aa"
p = "a"

Output:

false

Explanation:

"a" cannot match "aa".

Loading...
Wildcard Matching (`*` and `?`) - Strings