Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← 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)
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)
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
i
Z-box [1,1]
-
1
0
0
0
0
0
0
0
0
0
0
1
2
3
4
5
6
7
8
9
10
pattern (len=3)
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
i
Z-box [1,1]
-
1
0
0
0
0
0
0
0
0
0
0
1
2
3
4
5
6
7
8
9
10
pattern (len=3)
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
i
Z-box [4,6]
-
1
0
0
3
1
0
0
0
0
0
0
1
2
3
4
5
6
7
8
9
10
pattern (len=3)
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
i
Z-box [4,6]
-
1
0
0
3
1
0
0
0
0
0
0
1
2
3
4
5
6
7
8
9
10
pattern (len=3)
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
i
Z-box [8,10]
-
1
0
0
3
1
0
0
3
0
0
0
1
2
3
4
5
6
7
8
9
10
pattern (len=3)
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
-
1
0
0
3
1
0
0
3
1
0
0
1
2
3
4
5
6
7
8
9
10
pattern (len=3)
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
i
-
1
0
0
3
1
0
0
3
1
0
0
1
2
3
4
5
6
7
8
9
10
pattern (len=3)
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
i
-
1
0
0
3
1
0
0
3
1
0
0
1
2
3
4
5
6
7
8
9
10
pattern (len=3)
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
-
1
0
0
3
1
0
0
3
1
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
algo
master
.
io
Step:
Z-Algorithm: Build Z-array on "aab$aabxaab" (pattern + '$' + text), then find matches.