面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
课程表
Determine if all courses can be completed by analyzing prerequisite dependencies using indegree tracking and topological…
用队列实现栈
This problem tests your ability to simulate a LIFO stack using two queues while preserving all standard stack operations…
用栈实现队列
Implement a queue using two stacks, focusing on stack-based state management to achieve FIFO behavior in a queue.
滑动窗口最大值
Solve the "Sliding Window Maximum" problem using efficient techniques like the sliding window, deque, and priority queue…
扁平化嵌套列表迭代器
Implement an iterator to flatten a nested list of integers, accounting for potential nesting levels.
字符串中的第一个唯一字符
Find the index of the first non-repeating character in a string using efficient queue-driven state processing.
设计循环队列
Design a circular queue that allows efficient FIFO operations using linked-list pointer manipulation to optimize space u…
设计循环双端队列
Design and implement a circular deque using linked-list pointer manipulation, ensuring efficient insertion and deletion …
Dota2 参议院
The Dota2 Senate problem involves simulating voting rounds between Radiant and Dire senators until one party wins, using…
和至少为 K 的最短子数组
Find the shortest subarray with a sum of at least k using binary search and sliding window techniques.
环形子数组的最大和
Find the maximum sum of a circular subarray using state transition dynamic programming, optimizing for wraparound cases …
最近的请求次数
The "Number of Recent Calls" problem involves designing a class to efficiently track recent requests within a time windo…
戳印序列
Solve Stamping The Sequence with stack-based state management to convert string s to target using stamp efficiently.
按递增顺序显示卡牌
Determine the initial deck order to reveal cards in strictly increasing order using queue-driven simulation logic.
K 连续位的最小翻转次数
Determine the minimum number of k-length consecutive bit flips needed to convert all zeros to ones in a binary array eff…
带限制的子序列和
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…
满足不等式的最大值
Max Value of Equation asks to find the maximum value of a specific equation on a set of 2D points using sliding window t…
设计前中后队列
Implement a queue that efficiently handles push and pop operations at the front, middle, and back using pointer manipula…
从仓库到码头运输箱子
Optimize the minimum number of trips to deliver boxes to ports under strict ship constraints using dynamic programming t…
跳跃游戏 VI
Jump Game VI challenges you to maximize your score while jumping through an array using state transition dynamic program…
无法吃午餐的学生数量
Simulate a queue of students with sandwich preferences and determine how many can't eat based on available sandwiches.
找出游戏的获胜者
Find the winner of a circular game by simulating the elimination process with a queue-driven approach.
求出 MK 平均值
Find the MKAverage of a stream of integers using a queue-driven approach with efficient state management.
你可以安排的最多任务数目
Maximize the number of tasks that can be completed by efficiently using workers and magical pills.
买票需要的时间
Calculate the total time for a specific person to buy all their tickets using queue-driven state processing.
知道秘密的人数
Calculate how many people know a secret over n days using state transition dynamic programming and careful simulation of…
预算内的最多机器人数目
Determine the maximum number of consecutive robots you can operate without exceeding a given budget using efficient bina…
最长递增子序列 II
Determine the longest increasing subsequence in an array where consecutive elements differ by at most k using dynamic pr…
统计定界子数组的数目
Count all subarrays where the minimum and maximum match given bounds using efficient sliding window tracking techniques.
找到数据流中的连续整数
Design a data stream checker to identify consecutive integers from a stream, focusing on handling state transitions effi…
最大化城市的最小电量
Determine the maximum minimum power a city can achieve by strategically adding power stations using binary search and pr…
不间断子数组
Count all continuous subarrays efficiently using sliding window with running max-min state tracking for array consistenc…
购买水果需要的最少金币数
Calculate the minimum coins to buy fruits using state transition dynamic programming while handling rewards and purchase…
找到最大非递减数组的长度
Solve Find Maximum Non-decreasing Array Length with prefix-sum DP transitions that maximize kept segments while preservi…
划分数组得到最小的值之和
Solve the problem of dividing an array into subarrays to match specified bitwise AND values using dynamic programming.
使二进制数组全部等于 1 的最少操作次数 I
Find the minimum number of operations to make all elements of a binary array equal to one using sliding window and state…
统计 K 次操作以内得到非递减子数组的数目
This problem asks you to count non-decreasing subarrays in a given array after applying at most k operations.
设计路由器
Efficiently design a Router class to manage network packets with memory limits using array scanning and hash lookups.
统计极差最大为 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…