Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Rabin-Karp Algorithm
Bookmark
Input
Two Matches
Overlap
Middle Match
Hash Collision
Custom
text
=
abcabc
,
pattern
=
abc
text
pattern
0
1
2
3
4
5
a
b
c
a
b
c
a
b
c
0
1
2
patHash:
?
windowHash:
?
algo
master
.
io
Step:
Rabin-Karp: Use rolling hash to find all pattern occurrences in text.
Variable
Value
m
3
n
6
pattern
"abc"
Variable
Value
text
"abcabc"
undefined
-
0 / 17
Input
Two Matches
Overlap
Middle Match
Hash Collision
Custom
text
=
abcabc
,
pattern
=
abc
0 / 17
text
pattern
0
1
2
3
4
5
a
b
c
a
b
c
a
b
c
0
1
2
patHash:
?
windowHash:
?
algo
master
.
io
Step:
Rabin-Karp: Use rolling hash to find all pattern occurrences in text.
Visualization
Variables