题库chevron_right分类chevron_right滚动哈希
lock

滚动哈希

25 道题目
简单: 1中等: 9困难: 15

滚动哈希 是技术面试里最常出现的能力维度之一。建议先掌握基础题型的边界处理,再逐步过渡到模式识别和复杂度 trade-off。

面试场景

高频考察问题建模、边界条件与口头表达的清晰度。

常见误区

只背模板不解释为什么,容易在追问里失分。

练习策略

每轮练 3-5 题,固定复盘复杂度和可替代解法。

推荐练习顺序

#题目难度
187

重复的DNA序列

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

中等
214

最短回文串

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

困难
718

最长重复子数组

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

中等
1044

最长重复子串

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

困难
1147

段式回文

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

困难
1316

不同的循环子字符串

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

困难
1392

最长快乐前缀

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

困难
1461

检查一个字符串是否包含所有长度为 K 的二进制子串

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

中等
1923

最长公共子路径

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

困难
1960

两个回文子字符串长度的最大乘积

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

困难
2156

查找给定哈希值的子串

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

困难
2223

构造字符串的总得分和

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

困难
2261

含最多 K 个可整除元素的子数组

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

中等
2430

对字母串可执行的最大删除数

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

困难
3006

找出数组中的美丽下标 I

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

中等
3008

找出数组中的美丽下标 II

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

困难
3029

将单词恢复初始状态所需的最短时间 I

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

中等
3031

将单词恢复初始状态所需的最短时间 II

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

困难
3034

匹配模式数组的子数组数目 I

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

中等
3036

匹配模式数组的子数组数目 II

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

困难
3042

统计前后缀下标对 I

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

简单
3045

统计前后缀下标对 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 …

困难
3291

形成目标字符串需要的最少字符串数 I

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

中等
3292

形成目标字符串需要的最少字符串数 II

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

困难
3529

统计水平子串和垂直子串重叠格子的数目

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

中等

关联高频模式

LeetCode 滚动哈希题型题解:25题训练路线