Wildcard Matching

Problem Match string s against pattern p containing ? (matches any single character) and * (matches any sequence, including empty). The match must cover the ENTIRE string. Pin the exact semantics first, as variants exist.

Input / Output

  • Input: strings s and p.
  • Output: boolean — whether p fully matches s.

Constraints

  • Lengths up to 2000; O(mn) DP accepted; a greedy two-pointer runs O(m+n) average.

Example

  • s = "adceb", p = "*a*b" → true.
  • s = "acdcb", p = "a*c?b" → false.
  • s = "aa", p = "*" → true.
asked …
LeaderboardSalaryAccount