面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
找出字符串中第一个匹配项的下标
Locate the first occurrence of a substring within a string using a two-pointer scanning strategy and invariant tracking …
最短回文串
The Shortest Palindrome problem asks to transform a string into a palindrome by adding characters at the beginning, with…
重复的子字符串
Check if a string can be constructed by repeating a substring using string matching techniques.
另一棵树的子树
Determine if one binary tree is an exact subtree of another by comparing structure and node values recursively.
重复叠加字符串匹配
Find the minimum number of repetitions of string a to make string b a substring of the repeated string a.
旋转字符串
Determine if one string can be rotated into another by repeatedly shifting characters, leveraging string matching techni…
驼峰式匹配
Camelcase Matching is a medium difficulty problem where you match queries to a given pattern by inserting lowercase lett…
最长快乐前缀
Find the longest non-empty prefix of a string that also appears as its suffix, optimizing with rolling hash techniques.
找到所有好字符串
Find all good strings between two given strings without including a specified evil substring using dynamic programming.
数组中的字符串匹配
Identify all strings in an array that appear as substrings of other strings, focusing on array and string matching patte…
检查单词是否为句中其他单词的前缀
Determine the first word in a sentence where a given searchWord is a prefix using two-pointer scanning with string match…
最大重复子字符串
Find the maximum number of times a given word repeats consecutively in a string using state transition dynamic programmi…
通过连接另一个数组的子数组得到一个数组
Determine if you can sequentially select disjoint subarrays from nums matching each group in order using two-pointer sca…
统计包含给定前缀的字符串
Count how many words in a list start with a given prefix.
构造字符串的总得分和
Calculate the sum of scores of built strings by analyzing longest common prefixes with suffixes in a string using effici…
替换字符后匹配
Determine if a target substring can appear in a string after optional character replacements using given mappings effici…
对字母串可执行的最大删除数
Find the maximum number of deletions on a string using state transition dynamic programming and rolling hash techniques …
字符串转换
Find how many ways string s can be transformed into string t in exactly k operations using suffix rotations.
找出数组中的美丽下标 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…
第一个几乎相等子字符串的下标
Locate the first substring in s that is almost equal to pattern by allowing at most one character mismatch efficiently.
子字符串匹配模式
Determine if a pattern containing a single wildcard can match any substring of a given string efficiently.
最短匹配子字符串
Find the shortest substring in a string that matches a pattern with exactly two wildcards efficiently using binary searc…
字典序最小的生成字符串
Generate the lexicographically smallest string by merging str1 and str2 using a greedy approach with invariant checks.
统计水平子串和垂直子串重叠格子的数目
Efficiently count grid cells appearing in both horizontal and vertical occurrences of a given string pattern using array…