Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
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.
Variable
Value
concat
"aab$aabxaab"
m
3
n
7
pattern
"aab"
Variable
Value
text
"aabxaab"
totalLen
11
undefined
-
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.
Visualization
Variables