Wildcard Matching
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).

30:00

Wildcard Matching
hard
Topics
Companies

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).

Example 1:
Input: {"s":"aa","p":"*"}
Output: true
Constraints:
  • 0s.length,p.length20000 \leq s.\text{length}, p.\text{length} \leq 2000

  • s consists of lowercase English letters.

  • p consists of lowercase English letters, '?', and '*'.

Input
arr ={"s":"aa","p":"*"}

Match "aa" against pattern "*"

String s:

a

a

Pattern p:

*

DP Table (dp[i][j] = s[0..i] matches p[0..j])

a

a

*

T

F

F

F

F

F

Result: No Match

Current

True

* ?

Wildcards

Variables
No variables to display
DepthFunction Call
Stack empty
0/3