识别信号
- Do you understand how to handle edge cases like when there is no common prefix?
- Can you describe the trade-offs between vertical scanning and horizontal scanning?
- Able to explain space distribution in detail.
解题流程
- 1. 明确窗口/状态定义
- 2. 更新状态并维护约束
- 3. 用边界样例验证
常见失分点
- Failing to handle the case where no common prefix exists, returning an empty string instead of a valid result.
- Incorrectly distributing spaces when the number of spaces doesn't divide evenly.
- Not using bitwise operations correctly, leading to inefficient comparisons or incorrect results.
推荐题单梯度
最长公共前缀
Find the longest common prefix in an array of strings, returning an empty string if none exists.
文本左右对齐
Text Justification requires packing words into lines to match a specified width, ensuring even distribution of spaces.
最大单词长度乘积
The problem requires finding the maximum product of lengths of two words from an array, where the words don't share comm…
删除注释
Remove comments from a given C++ program source array, handling line and block comments.
写字符串需要的行数
Calculate how many lines are needed to write a string given individual letter widths, constrained to 100 pixels per line…
字母移位
Given a string and a shift array, shift the first i+1 letters of the string as specified in the array.
重新排列日志文件
Reorder Data in Log Files requires sorting letter-logs lexicographically while keeping digit-logs in original order for …
删列造序
The 'Delete Columns to Make Sorted' problem asks to remove unsorted columns from a string array, ensuring all columns ar…
等式方程的可满足性
Determine if it's possible to assign values to variables such that all equations are satisfied based on equality and ine…
字符流
Implement a StreamChecker that detects if any suffix of a character stream matches a given list of words using efficient…
删除子文件夹
Remove sub-folders in a filesystem by filtering out folders nested inside other folders.
竖直打印单词
Transform a string into vertical columns by arranging each word character in array positions while trimming trailing spa…
数组中的字符串匹配
Identify all strings in an array that appear as substrings of other strings, focusing on array and string matching patte…
重新排列字符串
Reorder characters in a string using a given indices array to reconstruct the intended output efficiently and correctly.
按键持续时间最长的键
Determine which key had the longest press duration in a sequence using array indices and string mapping, resolving ties …
检查两个字符串数组是否相等
Determine if two string arrays form identical strings by concatenating elements in order, handling subtle array-length m…
移动所有球到每个盒子所需的最小操作数
Solve the problem of finding the minimum operations to move balls to each box using an efficient approach with arrays an…
统计匹配检索规则的物品数量
Count Items Matching a Rule is an easy problem that tests array and string manipulation with conditions based on specifi…
截断句子
Truncate a sentence to contain only the first k words by converting it into an array of words.
作为子字符串出现在单词中的字符串数目
Count how many strings in an array appear as substrings within a given word by checking each pattern individually.
找出数组中的第 K 大整数
This problem asks to find the kth largest integer in an array of string numbers, highlighting sorting and string-based c…
执行操作后的变量值
Compute the final value of X by simulating each string operation in the array sequentially with careful tracking.
句子中的最多单词数
Find the maximum number of words in a single sentence from an array of sentences using array and string processing techn…
统计包含给定前缀的字符串
Count how many words in a list start with a given prefix.
由单个字符重复的最长子字符串
Solve Longest Substring of One Repeating Character by maintaining mergeable run information under character updates afte…
统计是给定字符串前缀的字符串数目
Count Prefixes of a Given String is a problem that involves finding the number of string prefixes in an array that match…
裁剪数字后查询第 K 小的数字
Solve the Query Kth Smallest Trimmed Number problem by efficiently trimming and sorting strings in an array to answer qu…
字母移位 II
Shift letters in a string using a sequence of range-based forward or backward operations efficiently with prefix sums.
收集垃圾的最少总时间
This problem asks you to find the minimum amount of time needed to collect all garbage in a city, focusing on array and …
字符串的前缀分数和
The 'Sum of Prefix Scores of Strings' problem involves calculating prefix scores for strings based on their occurrences …
判断两个事件是否存在冲突
Compare two same-day time intervals and check whether their inclusive endpoints overlap after converting HH:MM strings i…
距离字典两次编辑以内的单词
Identify all words in queries that can match dictionary entries with at most two character changes efficiently using arr…
数组中字符串的最大值
The problem requires finding the maximum value of alphanumeric strings in an array based on length or numeric value.
到目标字符串的最短距离
Find the shortest distance to a target string in a circular array with either left or right movement options.
统计范围内的元音字符串数
Count the number of strings that start and end with a vowel in given ranges within an array of words.
统计范围内的元音字符串数
Count the Number of Vowel Strings in Range asks to count vowel strings in a subarray of a given word list.
老人的数目
Determine how many passengers are over 60 years old based on their compressed details in an array of strings.
按分隔符拆分字符串
Split Strings by Separator requires iterating through an array of strings and splitting each by a given separator charac…
判别首字母缩略词
Check if a string can be formed by concatenating the first letters of each word in a given list.
查找包含给定字符的单词
Identify all indices of words containing a specific character using array and string traversal techniques efficiently.
转换字符串的最小成本 I
This problem asks to calculate the minimum cost to convert a string from source to target using specific character trans…
统计前后缀下标对 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 …
最长公共后缀查询
Find the index of the string in wordsContainer with the longest common suffix for each query efficiently using array and…
矩阵中的蛇
Solve the Snake in Matrix problem by simulating the snake's movement in a grid based on a series of directional commands…
两个字符串的切换距离
Find the minimum cost of transforming one string into another, considering operations between characters.
删除元素后 K 个字符串的最长公共前缀
Find the longest common prefix length of k strings after removing an element in the array.
统计水平子串和垂直子串重叠格子的数目
Efficiently count grid cells appearing in both horizontal and vertical occurrences of a given string pattern using array…
相邻字符串之间的最长公共前缀
Given an array of strings, find the longest common prefix length between adjacent strings after removals at each index.