Skip to interview prep
Apexed
Problem list124 / 125

124. Wildcard Pattern Matching

HardString algorithms

Return true if the pattern p matches the whole string s. In the pattern, "?" matches exactly one character and "*" matches any sequence of characters, including an empty one. Every other character matches itself.

Example 1

Input: s = "adceb", p = "*a*b"
Output: true

Example 2

Input: s = "cb", p = "?a"
Output: false

Constraints

  • 0 ≤ s.length, p.length ≤ 2000
  • s has lowercase letters; p has lowercase letters, "?" and "*"

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 6 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Wildcard Pattern Matching — coding interview practice — Apexed