Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
Z-Algorithm
Bookmark
Input
Two Matches
Overlapping
Repeated
No Match
Custom
text
=
aabxaab
,
pattern
=
aab
concat = pattern + "$" + text
Z[ ]
0
1
2
3
4
5
6
7
8
9
10
a
a
b
$
a
a
b
x
a
a
b
-
0
0
0
0
0
0
0
0
0
0
0
1
2
3
4
5
6
7
8
9
10
pattern (len=3)
algo
master
.
io
Step:
Z-Algorithm: Build Z-array on "aab$aabxaab" (pattern + '$' + text), then find matches.
0 / 31
Input
Two Matches
Overlapping
Repeated
No Match
Custom
text
=
aabxaab
,
pattern
=
aab
0 / 31
concat = pattern + "$" + text
Z[ ]
0
1
2
3
4
5
6
7
8
9
10
a
a
b
$
a
a
b
x
a
a
b
-
0
0
0
0
0
0
0
0
0
0
0
1
2
3
4
5
6
7
8
9
10
pattern (len=3)
algo
master
.
io
Step:
Z-Algorithm: Build Z-array on "aab$aabxaab" (pattern + '$' + text), then find matches.