Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Wildcard Matching
Bookmark
Memoization
Bottom-Up DP
Greedy
Input
Example 1 (false)
Example 2 (true)
Example 3 (false)
Example 4 (true)
Custom
s
=
aa
,
p
=
a
s
p
a
0
a
1
a
0
s
p
a
0
a
1
a
0
s
p
a
0
a
1
a
0
memo starts empty
s
p
a
0
a
1
a
0
0,0
1,1
match(0, 0)
s
p
a
0
a
1
a
0
0,0
1,1
p[0] = 'a' takes s[0] = 'a'
s
p
a
0
a
1
a
0
0,0
1,1
match(1, 1)
s
p
a
0
a
1
a
0
0,0
1,1
the pattern is exhausted
s
p
a
0
a
1
a
0
0,0
1,1
F
memo[(1,1)] = F
memo
(1,1) = F
s
p
a
0
a
1
a
0
0,0
F
1,1
F
memo[(0,0)] = F
memo
(1,1) = F
(0,0) = F
s
p
a
0
a
1
a
0
0,0
F
1,1
F
the pattern does not match
memo
(1,1) = F
(0,0) = F
algo
master
.
io
Step:
Does "aa" match the pattern "a"? (? = any char, * = any run)
0 / 8
Input
Example 1 (false)
Example 2 (true)
Example 3 (false)
Example 4 (true)
Custom
s
=
aa
,
p
=
a
0 / 8
algo
master
.
io
Step:
Does "aa" match the pattern "a"? (? = any char, * = any run)