Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Rabin-Karp Lab
Strings
Problem shape
Intermediate
4
8
15
16
23
42
Core idea
Compare rolling hashes of fixed-size windows against the pattern hash.
Step 1 / 5
Problem shape
Strings Intermediate
Rabin-Karp
Welcome to the Rabin-Karp algorithm lab. Compare rolling hashes of fixed-size windows against the pattern hash. Use it when: Use for multiple pattern checks or rolling hash practice. The time complexity is Average O(n + m), and the space complexity is O(1). The pseudocode is: patternHash = hash(pattern) windowHash = first window for each window if hashes match, verify characters roll hash to next window As you practice, track the state that changes and the condition that makes the algorithm stop.
Time
Average O(n + m)
Space
O(1)
Pseudocode
patternHash = hash(pattern)
windowHash = first window
for each window
if hashes match, verify characters
roll hash to next window 1.0x