题库chevron_right分类chevron_right字符串匹配
label

字符串匹配

33 道题目
简单: 10中等: 8困难: 15

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

面试场景

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

常见误区

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

练习策略

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

推荐练习顺序

#题目难度
28

找出字符串中第一个匹配项的下标

Locate the first occurrence of a substring within a string using a two-pointer scanning strategy and invariant tracking …

简单
214

最短回文串

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

困难
459

重复的子字符串

Check if a string can be constructed by repeating a substring using string matching techniques.

简单
572

另一棵树的子树

Determine if one binary tree is an exact subtree of another by comparing structure and node values recursively.

简单
686

重复叠加字符串匹配

Find the minimum number of repetitions of string a to make string b a substring of the repeated string a.

中等
796

旋转字符串

Determine if one string can be rotated into another by repeatedly shifting characters, leveraging string matching techni…

简单
1023

驼峰式匹配

Camelcase Matching is a medium difficulty problem where you match queries to a given pattern by inserting lowercase lett…

中等
1392

最长快乐前缀

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

困难
1397

找到所有好字符串

Find all good strings between two given strings without including a specified evil substring using dynamic programming.

困难
1408

数组中的字符串匹配

Identify all strings in an array that appear as substrings of other strings, focusing on array and string matching patte…

简单
1455

检查单词是否为句中其他单词的前缀

Determine the first word in a sentence where a given searchWord is a prefix using two-pointer scanning with string match…

简单
1668

最大重复子字符串

Find the maximum number of times a given word repeats consecutively in a string using state transition dynamic programmi…

简单
1764

通过连接另一个数组的子数组得到一个数组

Determine if you can sequentially select disjoint subarrays from nums matching each group in order using two-pointer sca…

中等
2185

统计包含给定前缀的字符串

Count how many words in a list start with a given prefix.

简单
2223

构造字符串的总得分和

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

困难
2301

替换字符后匹配

Determine if a target substring can appear in a string after optional character replacements using given mappings effici…

困难
2430

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

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

困难
2851

字符串转换

Find how many ways string s can be transformed into string t in exactly k operations using suffix rotations.

困难
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…

困难
3303

第一个几乎相等子字符串的下标

Locate the first substring in s that is almost equal to pattern by allowing at most one character mismatch efficiently.

困难
3407

子字符串匹配模式

Determine if a pattern containing a single wildcard can match any substring of a given string efficiently.

简单
3455

最短匹配子字符串

Find the shortest substring in a string that matches a pattern with exactly two wildcards efficiently using binary searc…

困难
3474

字典序最小的生成字符串

Generate the lexicographically smallest string by merging str1 and str2 using a greedy approach with invariant checks.

困难
3529

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

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

中等

关联高频模式

LeetCode 字符串匹配题型题解:33题训练路线