Skip to main content
LeetCode 44, Hard. Topics: String, Dynamic Programming, Greedy, Recursion. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 24 parametrized pytest cases, and a playground notebook:

Problem

Given an input string s and a pattern p, implement wildcard pattern matching with support for '?' and '*' where:
  • '?' Matches any single character.
  • '*' Matches any sequence of characters (including the empty sequence).
The matching should cover the entire input string (not partial).

Examples

Constraints

  • 0 <= s.length, p.length <= 2000
  • s contains only lowercase English letters.
  • p contains only lowercase English letters, '?' or '*'.

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

Last modified on September 7, 2026