面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
接雨水
Calculate the total trapped rain water using the elevation map array, leveraging dynamic programming and two-pointer pat…
柱状图中最大的矩形
Find the maximal rectangular area in a histogram using stack-based state management for precise bar tracking and width c…
最大矩形
Compute the largest rectangle of 1's in a binary matrix using dynamic programming and stack-based state transitions effi…
去除重复字母
Remove duplicate letters from a string to produce the lexicographically smallest result using stack-based state manageme…
拼接最大数
Create Maximum Number involves merging digits from two arrays while preserving order, maximizing the resulting number.
移掉 K 位数字
Remove K Digits requires selecting which digits to drop using a monotonic stack for the smallest possible integer result…
132 模式
Identify whether a given integer array contains a 132 pattern subsequence using efficient stack and search techniques.
下一个更大元素 I
Find the next greater element for each number in nums1 from the nums2 array using an optimized approach.
下一个更大元素 II
Solve the Next Greater Element II problem by using a stack-based state management approach for circular arrays.
最短无序连续子数组
Find the shortest unsorted continuous subarray that, if sorted, would sort the entire array.
最大二叉树
Construct a maximum binary tree by recursively selecting the largest element and dividing the array into left and right …
每日温度
In the Daily Temperatures problem, you need to find out how many days to wait for a warmer temperature based on given da…
最多能完成排序的块 II
Determine the maximum number of chunks you can split an array into so that sorting each chunk results in a fully sorted …
最多能完成排序的块
The Max Chunks To Make Sorted problem requires you to split an array into the maximum number of chunks that can be sorte…
车队
The Car Fleet problem asks how many car fleets will reach a target given their starting positions and speeds, considerin…
股票价格跨度
Design an efficient algorithm using stacks to calculate the stock span for daily price quotes.
子数组的最小值之和
Calculate the sum of minimum values across all subarrays of a given array modulo 10^9 + 7.
最大宽度坡
Find the maximum width of a ramp where nums[i] <= nums[j] for i < j using a two-pointer approach.
奇偶跳
Determine the number of valid starting indices in an array where you can reach the end with alternating odd and even jum…
前序遍历构造二叉搜索树
Construct a binary search tree directly from a preorder traversal array using stack-based state tracking efficiently.
链表中的下一个更大节点
Find the next greater value for each node in a linked list using monotonic stack techniques for efficient traversal.
不同字符的最小子序列
The Smallest Subsequence of Distinct Characters problem asks you to find the lexicographically smallest subsequence of a…
表现良好的最长时间段
The Longest Well-Performing Interval problem challenges you to find the longest subarray where tiring days exceed non-ti…
叶值的最小代价生成树
Compute the minimum sum of non-leaf nodes in a binary tree formed from array leaves using dynamic programming efficientl…
商品折扣后的最终价格
Calculate final prices with discounts applied in a shop using a stack-based state management approach to find the correc…
统计全 1 子矩形
Count Submatrices With All Ones is a dynamic programming problem focusing on submatrix counting using an efficient row-b…
形成目标数组的子数组最少增加次数
The problem asks for the minimum number of operations to transform an initial array of zeros into a target array using s…
删除最短的子数组使剩余数组有序
Find the shortest subarray to remove in order to make an array non-decreasing using binary search and two-pointer techni…
找出最具竞争力的子序列
Identify the lexicographically smallest subsequence of size k using stack-based greedy selection in array traversal.
车队 II
Car Fleet II involves calculating collision times between cars traveling at different speeds along a one-lane road using…
好子数组的最大分数
Maximize the score of a good subarray using binary search to explore the valid answer space with a focus on two-pointer …
子数组最小乘积的最大值
The problem asks to find the maximum min-product of any non-empty subarray of nums.
队列中可以看到的人数
Compute how many people each person in a queue can see to their right using efficient stack-based state management.
游戏中弱角色的数量
Identify all weak characters in a game by analyzing attack and defense values using a stack-based greedy sorting approac…
含特定字母的最小子序列
Find the lexicographically smallest subsequence of length k with at least repetition occurrences of a given letter using…
子数组范围和
Compute the total sum of ranges for all contiguous subarrays efficiently using stack-based state management techniques.
巫师的总力量和
The Sum of Total Strength of Wizards problem asks for the sum of the total strengths of all contiguous subarrays of wiza…
使数组按非递减顺序排列
Determine the minimum steps to make an array non-decreasing using linked-list pointer manipulation and monotonic stack t…
元素值大于变化阈值的子数组
Find the size of a subarray with all elements greater than threshold divided by length using stack-based state managemen…
下一个更大元素 IV
Find the second greater integer for each element in an array using binary search and monotonic stack techniques.
从链表中移除节点
This problem requires removing nodes from a linked list when a larger node exists to their right, testing pointer manipu…
网格图中最少访问的格子数
Determine the minimum number of cells to visit in a grid using state transition dynamic programming and efficient traver…
最大和查询
Find the maximum sum of paired elements from two arrays under query constraints using efficient binary search techniques…
操作使得分最大
Maximize the score by applying operations on a subarray at most k times, utilizing stack-based state management.
美丽塔 I
Solve Beautiful Towers I by testing each peak and enforcing mountain limits with monotonic stack style height propagatio…
美丽塔 II
Maximize tower configurations with the stack-based approach while ensuring mountain-like patterns in this medium difficu…
找到 Alice 和 Bob 可以相遇的建筑
Determine the leftmost building where Alice and Bob can meet using a binary search over valid move sequences.
找到最大非递减数组的长度
Solve Find Maximum Non-decreasing Array Length with prefix-sum DP transitions that maximize kept segments while preservi…
边界元素是最大值的子数组数目
Count the subarrays where the first and last elements are the largest in the subarray, utilizing binary search over vali…
使数组等于目标数组所需的最少操作次数
This problem requires calculating the minimum number of operations to transform one array into another using state trans…
统计 K 次操作以内得到非递减子数组的数目
This problem asks you to count non-decreasing subarrays in a given array after applying at most k operations.
最多 K 个元素的子数组的最值之和
Compute the sum of maximum and minimum values in all subarrays up to size k using efficient stack-based state management…
非递减数组的最大长度
Determine the maximum size of a non-decreasing array by replacing subarrays with their maximum values efficiently.
将所有元素变为 0 的最少操作次数
Calculate the fewest operations to turn all numbers in an array to zero using subarray minimum elimination strategy.