面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
无重复字符的最长子串
Find the length of the longest substring without repeating characters using a sliding window and hash map to track state…
串联所有单词的子串
Find all starting indices of substrings in a string that are concatenations of a given list of words.
最小覆盖子串
Find the smallest substring of s containing all characters from t using a sliding window with running state updates for …
重复的DNA序列
Solve Repeated DNA Sequences by sliding a length-10 window and tracking seen patterns with a hash set or bitmask.
长度最小的子数组
Find the minimal length of a subarray whose sum is greater than or equal to the target using efficient algorithms.
存在重复元素 II
Check if any two equal numbers exist within k indices using array scanning and hash table lookup efficiently.
存在重复元素 III
The problem involves finding a pair of indices in an array where the index and value differences are within given limits…
滑动窗口最大值
Solve the "Sliding Window Maximum" problem using efficient techniques like the sliding window, deque, and priority queue…
至少有 K 个重复字符的最长子串
Find the length of the longest substring where every character appears at least k times using sliding window and divide-…
等差数列划分
Count the number of arithmetic subarrays in a given integer array using dynamic programming.
替换后的最长重复字符
Find the length of the longest substring after at most k replacements using a sliding window and character count trackin…
找到字符串中所有字母异位词
Find all starting indices of p's anagrams in s using sliding window and hash table approach.
滑动窗口中位数
Compute the median for each sliding window of size k in an array using efficient array scanning and hash lookup techniqu…
字符串的排列
Check if a string contains a permutation of another string using two-pointer scanning and hash table techniques.
最长和谐子序列
Find the length of the longest harmonious subsequence in an integer array using array scanning and hash-based frequency …
最小区间
Find the minimal range covering at least one number from each of k sorted lists using array scanning and hash lookup eff…
子数组最大平均数 I
Find the maximum average of any contiguous subarray of length k in a given integer array using a sliding window approach…
找到 K 个最接近的元素
Identify the k integers closest to a target x in a sorted array using binary search and two-pointer strategies efficient…
三个无重叠子数组的最大和
Maximize the sum of three non-overlapping subarrays with length k in an integer array using dynamic programming.
乘积小于 K 的子数组
Count subarrays with a product strictly less than a given value k using efficient algorithms like binary search and slid…
最长重复子数组
Find the maximum length of a subarray that appears in both given integer arrays using dynamic programming.
新 21 点
Calculate the probability Alice reaches at most n points using state transition dynamic programming efficiently.
和至少为 K 的最短子数组
Find the shortest subarray with a sum of at least k using binary search and sliding window techniques.
水果成篮
The Fruit Into Baskets problem requires finding the maximum number of fruits you can pick from a row of trees under spec…
和相同的二元子数组
Count all contiguous subarrays in a binary array whose elements sum exactly to a given goal using prefix sums efficientl…
最长湍流子数组
Find the length of the longest subarray where element comparisons alternate, using state transition dynamic programming …
K 个不同整数的子数组
Find subarrays with exactly k distinct integers in an integer array using sliding window and hash lookup techniques.
K 连续位的最小翻转次数
Determine the minimum number of k-length consecutive bit flips needed to convert all zeros to ones in a binary array eff…
最大连续1的个数 III
Find the longest consecutive ones in a binary array by optimally flipping at most k zeros using sliding window technique…
子串能表示从 1 到 N 数字的二进制串
Check if binary string contains all integers from 1 to n as substrings, leveraging sliding window and bit manipulation t…
两个无重叠子数组的最大和
Find the maximum sum of two non-overlapping subarrays by efficiently using state transition dynamic programming.
移动石子直到连续 II
Determine the minimum and maximum moves to make stones consecutive using sliding window and endpoint adjustments efficie…
最长重复子串
Find the longest duplicated substring in a string using binary search, sliding window, and rolling hash techniques.
爱生气的书店老板
Maximize satisfied customers in a bookstore by strategically suppressing the owner's grumpy minutes using a sliding wind…
单字符重复子串的最大长度
Find the maximum length of a repeated character substring after swapping two characters using a sliding window approach …
尽可能使字符串相等
Optimize substring transformations using a binary search approach to maximize the change within a budget.
替换子串得到平衡字符串
Determine the minimum substring length to replace in order to balance a string of Q, W, E, and R characters efficiently.
统计「优美子数组」
The problem requires counting subarrays with exactly k odd numbers using an efficient array scanning approach.
子串的最大出现次数
Find the maximum number of occurrences of any valid substring in a given string with specific constraints on letter coun…
大小为 K 且平均值大于等于阈值的子数组数目
Given an array, find the number of sub-arrays of size k with an average greater than or equal to a given threshold.
包含所有三种字符的子字符串数目
Count all substrings containing at least one of each character a, b, and c using a sliding window approach efficiently.
可获得的最大点数
Maximize your score by selecting k cards from the beginning or end of the array using a sliding window approach.
带限制的子序列和
Solve the Constrained Subsequence Sum problem using dynamic programming, sliding window, and priority queues to maximize…
绝对差不超过限制的最长连续子数组
Find the longest subarray with elements whose absolute difference is within a specified limit using a sliding window app…
定长子串中元音的最大数目
Find the maximum number of vowels in a substring of a given length in a string using a sliding window approach.
找两个和为目标值且不重叠的子数组
Find two non-overlapping sub-arrays with a given target sum and return the minimal total length efficiently using array …
删掉一个元素以后全为 1 的最长子数组
Solve LeetCode 1493 by tracking runs of 1s around one deletion using a tight sliding window or state transition DP.
满足不等式的最大值
Max Value of Equation asks to find the maximum value of a specific equation on a set of 2D points using sliding window t…
可见点的最大数目
Determine the maximum number of points visible from a fixed location within a given angle using a sliding window approac…
拆炸弹
Defuse the Bomb uses a sliding window to update a circular array based on a key, with efficient state updates.
将 x 减到 0 的最小操作数
Find the minimum number of operations to reduce a value x to zero by removing elements from an array.
删除子数组的最大得分
Maximize the score by erasing a subarray with unique elements in an array of integers.
得到连续 K 个 1 的最少相邻交换次数
Find the minimum number of adjacent swaps to gather k consecutive ones in a binary array using sliding window logic.
最长的美好子字符串
Find the longest nice substring in a given string using the sliding window technique with running state updates.
最高频元素的频数
Maximize the frequency of an element in an array by incrementing at most `k` elements. Use binary search and greedy tech…
所有元音按顺序排布的最长子字符串
Find the longest substring of all vowels in order within a given string of vowels using sliding window technique.
跳跃游戏 VII
The problem asks to determine if we can reach the last index of a binary string, with a set range of jumps between indic…
长度为三且各字符不同的子字符串
Count all substrings of length three in a string where each character is unique using sliding window techniques efficien…
使二进制字符串字符交替的最少反转次数
Find the minimum number of flips to make a binary string alternate, using state transition dynamic programming.
学生分数的最小差值
Minimize the difference between the highest and lowest of k student scores using a sliding window approach.
使数组连续的最少操作数
Find the minimum number of operations to make an array continuous by modifying elements using array scanning and hash lo…
考试的最大困扰度
Maximize the Confusion of an Exam requires adjusting at most k answers to create the longest consecutive true or false s…
半径为 k 的子数组平均值
Efficiently calculate the k-radius average for subarrays using sliding window technique.
摘水果
Compute the maximum fruits collectable on an infinite line by moving at most k steps from a start position efficiently.
最少交换次数来组合所有的 1 II
Solve the minimum swaps to group all 1's together in a circular binary array using an optimized sliding window approach.
查找给定哈希值的子串
Locate the first substring of length k whose rolling hash matches the given hashValue using a sliding window approach.
必须拿起的最小连续卡牌数
Solve Minimum Consecutive Cards to Pick Up by tracking each card's last index and minimizing duplicate spans during one …
找到一个数字的 K 美丽值
Calculate the k-beauty of a number by counting substrings of length k that divide the original number evenly using a sli…
毯子覆盖的最多白色砖块数
Solve Maximum White Tiles Covered by a Carpet by sorting intervals, checking optimal carpet starts, and counting full pl…
统计得分小于 K 的子数组数目
Count all non-empty subarrays whose score, defined as sum times length, is strictly less than a given integer k efficien…
得到 K 个黑块的最少涂色次数
Given a string of blocks, determine the minimum number of recolors needed to get k consecutive black blocks.
预算内的最多机器人数目
Determine the maximum number of consecutive robots you can operate without exceeding a given budget using efficient bina…
最长优雅子数组
Find the length of the longest nice subarray where the bitwise AND of all pairs of elements in the subarray is zero.
按位或最大的最小子数组长度
Find the smallest subarrays with the maximum bitwise OR for each starting index in an array.
统计定界子数组的数目
Count all subarrays where the minimum and maximum match given bounds using efficient sliding window tracking techniques.
长度为 K 子数组中的最大和
Find the maximum sum of all distinct-element subarrays of length k using array scanning and hash lookup techniques.
每种字符至少取 K 个
Find the minimum number of minutes needed to take at least k of each character from both ends of a string.
最大化城市的最小电量
Determine the maximum minimum power a city can achieve by strategically adding power stations using binary search and pr…
统计好子数组的数目
Count the number of subarrays that contain at least k pairs of equal elements using array scanning and hash lookup.
两个线段获得的最多奖品
Maximize the total prizes by choosing two segments of length k on a sorted line of prize positions efficiently using bin…
滑动子数组的美丽值
Compute the xth smallest negative number in each sliding subarray using array scanning and hash frequency tracking effic…
找到最长的半重复子字符串
Find the length of the longest substring where at most one adjacent pair of digits repeats, using a sliding window appro…
统计没有收到请求的服务器数目
Count Zero Request Servers finds the number of servers with zero requests during specific time intervals for a given set…
最长奇偶子数组
Determine the length of the longest subarray where elements alternate even and odd while staying below a given threshold…
不间断子数组
Count all continuous subarrays efficiently using sliding window with running max-min state tracking for array consistenc…
数组的最大美丽值
Find the maximum beauty of an array by adjusting elements within a range using binary search and sliding window techniqu…
最长合法子字符串的长度
This problem asks for the longest valid substring of a word that doesn't contain any substrings from a forbidden list.
统计完全子数组的数目
Count Complete Subarrays in an Array requires scanning the array while tracking elements to detect subarrays with all di…
找出最长等值子数组
Find the maximum length of an equal subarray after removing up to k elements using array scanning and hash-based index t…
几乎唯一子数组的最大和
Find the maximum sum of subarrays that contain at least m distinct elements using array scanning and hash lookups effici…
无限数组的最短子数组
Find the shortest subarray in an infinite array that sums to a given target using array scanning and hash lookup.
和带限制的子多重集合的数目
This problem asks you to count the number of sub-multisets within a given array that have a sum in a specified range.
最短且字典序最小的美丽子字符串
Find the shortest beautiful substring in a binary string and return the lexicographically smallest option efficiently us…
找出强数对的最大异或值 I
Find the maximum XOR of any strong pair in an integer array using array scanning and hash-based lookups efficiently.
找出强数对的最大异或值 II
Find the maximum XOR among strong pairs in an array using array scanning and hash-based lookups efficiently.
统计完全子字符串
Count Complete Substrings involves finding substrings where each character appears exactly k times with constraints on a…
最多 K 个重复元素的最长子数组
Find the maximum length subarray where each number appears at most k times using array scanning and hash lookups.
统计最大元素出现至少 K 次的子数组
Find the number of subarrays where the maximum element appears at least k times using a sliding window approach.
执行操作使频率分数最大
Maximize the frequency score by applying up to k operations on a sorted array using binary search over valid answer spac…
找出出现至少三次的最长特殊子字符串 I
Find the longest special substring in a string that appears at least three times, or return -1 if no such substring exis…
找出出现至少三次的最长特殊子字符串 II
Find the longest special substring that occurs at least three times in a given string using binary search and hash table…
将数组分成最小总代价的子数组 II
This problem asks to divide an array into subarrays with a minimal cost and certain constraints on subarray positions.
拾起 K 个 1 需要的最少行动次数
Find the minimum number of moves to pick exactly k ones from a binary array, considering a constraint on changes.
每个字符最多出现两次的最长子字符串
Find the maximum length substring where some substring occurs at least twice using a sliding window and hash mapping str…
或值至少 K 的最短子数组 I
Find the shortest non-empty subarray in nums whose bitwise OR reaches at least k using sliding window efficiently.
或值至少为 K 的最短子数组 II
Find the length of the shortest subarray where the bitwise OR of all its elements is at least a given value.
找出唯一性数组的中位数
Given a nums array, find the median of its uniqueness array by considering all subarrays and their distinct element coun…
使二进制数组全部等于 1 的最少操作次数 I
Find the minimum number of operations to make all elements of a binary array equal to one using sliding window and state…
交替组 I
Count all alternating groups in a circular array by tracking tiles with distinct neighbors efficiently using sliding win…
交替组 II
Solve the problem of counting alternating groups in a circle of tiles using a sliding window approach.
统计 1 显著的字符串的数量
Count the number of substrings in a binary string with dominant ones, using a sliding window approach with state updates…
长度为 K 的子数组的能量值 I
Given an array, find the power of all subarrays of size k using a sliding window approach.
长度为 K 的子数组的能量值 II
Compute the power of all k-size subarrays in an array using sliding window with running state updates efficiently.
统计满足 K 约束的子字符串数量 I
Count all substrings in a binary string that meet a given k-constraint using an efficient sliding window approach.
统计满足 K 约束的子字符串数量 II
Count Substrings That Satisfy K-Constraint II requires finding valid substrings in a binary string based on a k-constrai…
统计重新排列后包含另一个字符串的子字符串数目 I
Count the number of valid substrings in word1 that can be rearranged to contain word2 as a prefix.
统计重新排列后包含另一个字符串的子字符串数目 II
Count Substrings That Can Be Rearranged to Contain a String II involves identifying valid substrings with a sliding wind…
元音辅音字符串计数 I
Count all substrings containing every vowel and exactly k consonants using a sliding window and hash map state tracking.
元音辅音字符串计数 II
Count the number of substrings containing all vowels and exactly k consonants using a sliding window technique.
计算子数组的 x-sum I
Compute the x-sum of every subarray of length k efficiently using array scanning combined with hash lookup techniques.
计算子数组的 x-sum II
Calculate the x-sum for every k-length subarray using efficient array scanning and hash-based counting techniques.
字符至少出现 K 次的子字符串 I
Calculate the total number of substrings where at least one character repeats k times using a sliding window efficiently…
执行操作后元素的最高频率 I
Maximize the frequency of an element in an array after performing a series of operations to find the best possible resul…
执行操作后元素的最高频率 II
Determine the maximum frequency of any element after performing limited operations using binary search and sliding windo…
最小正和子数组
Find the minimum sum of any subarray of size between l and r with a positive total using efficient sliding window logic.
最长乘积等价子数组
This problem involves finding the longest subarray where the product equals the LCM multiplied by the GCD, leveraging a …
收集连续 K 个袋子可以获得的最多硬币数量
Solve the problem of maximizing coins from selecting k consecutive bags, using binary search and sliding window techniqu…
统计 K 次操作以内得到非递减子数组的数目
This problem asks you to count non-decreasing subarrays in a given array after applying at most k operations.
重新安排会议得到最多空余时间 I
Maximize free time by rescheduling up to k non-overlapping meetings within a fixed event using sliding window updates.
奇偶频次间的最大差值 II
Find the maximum difference between even and odd character frequencies in substrings using sliding window updates effici…
使 K 个子数组内元素相等的最少操作数
Compute the minimum operations to ensure at least k non-overlapping subarrays of size x have all equal elements efficien…
统计极差最大为 K 的分割方式数
Count the number of valid ways to partition an array into contiguous segments where max-min difference is at most k.
计数质数间隔平衡子数组
Count the number of prime-gap balanced subarrays in an integer array using sliding window techniques and running state u…