LeetCodechevron_rightCategorieschevron_rightrolling hash
lock

rolling hash

25 problems
Easy: 1Medium: 9Hard: 15

rolling hash is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.

Interview Signal

Frequently tests problem modeling, edge handling, and verbal clarity.

Common Pitfall

Template-only answers break under follow-up questioning.

Practice Strategy

Practice in 3-5 problem rounds and always review complexity alternatives.

Recommended Progression

#TitleDifficulty
187

Repeated DNA Sequences

Solve Repeated DNA Sequences by sliding a length-10 window and tracking seen patterns with a hash set or bitmask.

Medium
214

Shortest Palindrome

The Shortest Palindrome problem asks to transform a string into a palindrome by adding characters at the beginning, with…

Hard
718

Maximum Length of Repeated Subarray

Find the maximum length of a subarray that appears in both given integer arrays using dynamic programming.

Medium
1044

Longest Duplicate Substring

Find the longest duplicated substring in a string using binary search, sliding window, and rolling hash techniques.

Hard
1147

Longest Chunked Palindrome Decomposition

Solve the "Longest Chunked Palindrome Decomposition" problem by using dynamic programming and string manipulation techni…

Hard
1316

Distinct Echo Substrings

Count the distinct non-empty substrings of a given string that can be formed as the concatenation of a string with itsel…

Hard
1392

Longest Happy Prefix

Find the longest non-empty prefix of a string that also appears as its suffix, optimizing with rolling hash techniques.

Hard
1461

Check If a String Contains All Binary Codes of Size K

Determine if every possible binary string of length k exists as a substring within a given binary string s efficiently u…

Medium
1923

Longest Common Subpath

The Longest Common Subpath problem requires finding the longest subpath shared by all paths in a graph using binary sear…

Hard
1960

Maximum Product of the Length of Two Palindromic Substrings

Find the maximum product of lengths of two non-overlapping odd-length palindromic substrings using string and rolling ha…

Hard
2156

Find Substring With Given Hash Value

Locate the first substring of length k whose rolling hash matches the given hashValue using a sliding window approach.

Hard
2223

Sum of Scores of Built Strings

Calculate the sum of scores of built strings by analyzing longest common prefixes with suffixes in a string using effici…

Hard
2261

K Divisible Elements Subarrays

Count all distinct subarrays with at most k elements divisible by p using array scanning and hash lookup techniques effi…

Medium
2430

Maximum Deletions on a String

Find the maximum number of deletions on a string using state transition dynamic programming and rolling hash techniques …

Hard
3006

Find Beautiful Indices in the Given Array I

Identify all beautiful indices where substring a appears and a nearby substring b exists within distance k efficiently.

Medium
3008

Find Beautiful Indices in the Given Array II

Find Beautiful Indices in the Given Array II challenges you to use binary search and string matching techniques.

Hard
3029

Minimum Time to Revert Word to Initial State I

Determine the minimum seconds to revert a string to its original state using repeated prefix shifts of length k efficien…

Medium
3031

Minimum Time to Revert Word to Initial State II

The problem asks to calculate the minimum time required to revert a string to its initial state using specific operation…

Hard
3034

Number of Subarrays That Match a Pattern I

Count all subarrays in a given integer array that strictly follow a defined numeric pattern using rolling hash checks ef…

Medium
3036

Number of Subarrays That Match a Pattern II

Count subarrays matching a pattern of relative values using array transformation and rolling hash techniques.

Hard
3042

Count Prefix and Suffix Pairs I

Count all index pairs where one word is both a prefix and suffix of another, using efficient array and string checks.

Easy
3045

Count Prefix and Suffix Pairs II

Count the number of index pairs in a string array where one word is both a prefix and suffix of another using array and …

Hard
3291

Minimum Number of Valid Strings to Form Target I

Use dynamic programming to split target into the fewest prefixes that match any word prefix, while ruling out dead posit…

Medium
3292

Minimum Number of Valid Strings to Form Target II

Compute the minimum number of valid strings from an array needed to construct a given target string efficiently using dy…

Hard
3529

Count Cells in Overlapping Horizontal and Vertical Substrings

Efficiently count grid cells appearing in both horizontal and vertical occurrences of a given string pattern using array…

Medium

Related Patterns

Rolling Hash LeetCode Problems: 25 Solutions