Wildcard Pattern Matching

hard
Unit 22 · Graphs III0/1 to milestone

Match a whole string against a pattern where ? matches any single character and * matches any sequence (including empty). Implement:

  • match_dp(s, p): dynamic programming over prefixes
  • match_greedy(s, p): the O(1)-space greedy algorithm that remembers the last * and backtracks to it on mismatch
Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Wildcard Pattern Matching · TechGradify