面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
重复的DNA序列
Solve Repeated DNA Sequences by sliding a length-10 window and tracking seen patterns with a hash set or bitmask.
最短回文串
The Shortest Palindrome problem asks to transform a string into a palindrome by adding characters at the beginning, with…
TinyURL 的加密与解密
Design a class that encodes and decodes URLs using a URL shortening approach based on hash tables and strings.
另一棵树的子树
Determine if one binary tree is an exact subtree of another by comparing structure and node values recursively.
设计哈希集合
Implement a custom HashSet without built-in libraries using array scanning and hash lookup for efficient membership chec…
设计哈希映射
Implement a custom HashMap from scratch using array scanning and hash lookup without built-in libraries for efficient ke…
最长重复子数组
Find the maximum length of a subarray that appears in both given integer arrays using dynamic programming.
最长重复子串
Find the longest duplicated substring in a string using binary search, sliding window, and rolling hash techniques.
段式回文
Solve the "Longest Chunked Palindrome Decomposition" problem by using dynamic programming and string manipulation techni…
不同的循环子字符串
Count the distinct non-empty substrings of a given string that can be formed as the concatenation of a string with itsel…
最长快乐前缀
Find the longest non-empty prefix of a string that also appears as its suffix, optimizing with rolling hash techniques.
检查一个字符串是否包含所有长度为 K 的二进制子串
Determine if every possible binary string of length k exists as a substring within a given binary string s efficiently u…
最长公共子路径
The Longest Common Subpath problem requires finding the longest subpath shared by all paths in a graph using binary sear…
删除系统中的重复文件夹
Solve Delete Duplicate Folders in System by building a trie, serializing child subtrees, and deleting repeated non-empty…
两个回文子字符串长度的最大乘积
Find the maximum product of lengths of two non-overlapping odd-length palindromic substrings using string and rolling ha…
查找给定哈希值的子串
Locate the first substring of length k whose rolling hash matches the given hashValue using a sliding window approach.
构造字符串的总得分和
Calculate the sum of scores of built strings by analyzing longest common prefixes with suffixes in a string using effici…
含最多 K 个可整除元素的子数组
Count all distinct subarrays with at most k elements divisible by p using array scanning and hash lookup techniques effi…
对字母串可执行的最大删除数
Find the maximum number of deletions on a string using state transition dynamic programming and rolling hash techniques …
找出数组中的美丽下标 I
Identify all beautiful indices where substring a appears and a nearby substring b exists within distance k efficiently.
找出数组中的美丽下标 II
Find Beautiful Indices in the Given Array II challenges you to use binary search and string matching techniques.
将单词恢复初始状态所需的最短时间 I
Determine the minimum seconds to revert a string to its original state using repeated prefix shifts of length k efficien…
将单词恢复初始状态所需的最短时间 II
The problem asks to calculate the minimum time required to revert a string to its initial state using specific operation…
匹配模式数组的子数组数目 I
Count all subarrays in a given integer array that strictly follow a defined numeric pattern using rolling hash checks ef…
匹配模式数组的子数组数目 II
Count subarrays matching a pattern of relative values using array transformation and rolling hash techniques.
统计前后缀下标对 I
Count all index pairs where one word is both a prefix and suffix of another, using efficient array and string checks.
统计前后缀下标对 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 …
形成目标字符串需要的最少字符串数 I
Use dynamic programming to split target into the fewest prefixes that match any word prefix, while ruling out dead posit…
形成目标字符串需要的最少字符串数 II
Compute the minimum number of valid strings from an array needed to construct a given target string efficiently using dy…
判断 DFS 字符串是否是回文串
Determine if strings formed by DFS traversal of a tree are palindromes using array scanning and hash lookups efficiently…
统计水平子串和垂直子串重叠格子的数目
Efficiently count grid cells appearing in both horizontal and vertical occurrences of a given string pattern using array…