Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← 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:
?
text
pattern
0
1
2
3
4
5
a
b
c
a
b
c
a
b
c
0
1
2
patHash:
?
windowHash:
?
text
pattern
0
1
2
3
4
5
a
b
c
a
b
c
a
b
c
0
1
2
patHash:
hashing...
windowHash:
?
text
pattern
0
1
2
3
4
5
a
b
c
a
b
c
a
b
c
0
1
2
patHash:
1,026
windowHash:
?
text
pattern
0
1
2
3
4
5
a
b
c
a
b
c
a
b
c
0
1
2
patHash:
1,026
windowHash:
hashing...
text
pattern
0
1
2
3
4
5
a
b
c
a
b
c
a
b
c
0
1
2
patHash:
1,026
windowHash:
1,026
Hash match! Verifying...
text
pattern
0
1
2
3
4
5
a
b
c
a
b
c
window
a
b
c
0
1
2
patHash:
1,026
windowHash:
1,026
Hash match! Verifying...
text
pattern
0
1
2
3
4
5
a
b
c
a
b
c
window
a
b
c
0
1
2
patHash:
1,026
windowHash:
2,016
text
pattern
0
1
2
3
4
5
a
b
c
a
b
c
window
a
b
c
0
1
2
patHash:
1,026
windowHash:
2,916
text
pattern
0
1
2
3
4
5
a
b
c
a
b
c
window
a
b
c
0
1
2
patHash:
1,026
windowHash:
1,026
Hash match! Verifying...
text
pattern
0
1
2
3
4
5
a
b
c
a
b
c
a
b
c
0
1
2
patHash:
1,026
windowHash:
1,026
Hash match! Verifying...
algo
master
.
io
Step:
Rabin-Karp: Use rolling hash to find all pattern occurrences in text.
0 / 17
Input
Two Matches
Overlap
Middle Match
Hash Collision
Custom
text
=
abcabc
,
pattern
=
abc
0 / 17
algo
master
.
io
Step:
Rabin-Karp: Use rolling hash to find all pattern occurrences in text.