面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
天际线问题
The Skyline Problem requires calculating a city's silhouette using array manipulation and divide-and-conquer techniques …
存在重复元素 III
The problem involves finding a pair of indices in an array where the index and value differences are within given limits…
计算右侧小于当前元素的个数
Solve the Count of Smaller Numbers After Self problem using binary search and optimized algorithms.
区间和的个数
Count the number of subarray sums within a given inclusive range using optimized divide-and-conquer techniques efficient…
将数据流变为多个不相交区间
The problem involves designing a class to summarize a data stream of non-negative integers as disjoint intervals using b…
矩形区域不超过 K 的最大数值和
Solve the "Max Sum of Rectangle No Larger Than K" problem using binary search over the valid sum space to optimize space…
132 模式
Identify whether a given integer array contains a 132 pattern subsequence using efficient stack and search techniques.
翻转对
Count the number of reverse pairs in a given integer array using efficient algorithms like binary search and merge sort.
非重叠矩形中的随机点
Design an algorithm to pick random points within non-overlapping rectangles using binary search and reservoir sampling.
掉落的方块
Solve Falling Squares by efficiently computing maximum stack heights using arrays with segment tree optimization techniq…
Range 模块
Design a RangeModule to track and query half-open intervals using segment trees or ordered sets.
我的日程安排表 I
Implement a calendar supporting non-overlapping event bookings using binary search for efficient insertion and conflict …
我的日程安排表 II
Implement a calendar that allows double bookings but prevents triple bookings, managing overlapping intervals efficientl…
我的日程安排表 III
Implement My Calendar III to track maximum overlapping events efficiently using binary search and segment tree technique…
矩形面积 II
The problem involves calculating the total area covered by multiple rectangles, ensuring overlap is counted only once.
考场就座
Simulate an exam room where each student chooses a seat maximizing distance to others, using design plus heap structures…
最大频率栈
Design a stack-like data structure to manage elements and handle frequent stack operations, including popping the most f…
奇偶跳
Determine the number of valid starting indices in an array where you can reach the end with alternating odd and even jum…
推文计数
Design an efficient solution to track and retrieve tweet counts over different frequencies using binary search and hash …
点菜展示表
Generate a restaurant display table from orders by counting each food item per table using array scanning and hash looku…
绝对差不超过限制的最长连续子数组
Find the longest subarray with elements whose absolute difference is within a specified limit using a sliding window app…
找到处理最多请求的服务器
Given k servers and a series of requests, find the busiest server(s) using greedy strategies and efficient server tracki…
通过指令创建有序数组
The problem asks to compute the cost of inserting elements into a sorted array using a series of instructions.
数组的最小偏移量
Given a positive integer array, repeatedly double or halve elements to minimize the difference between its largest and s…
绝对差值和
Minimize the absolute sum difference between two integer arrays by replacing at most one element from the first array.
求出 MK 平均值
Find the MKAverage of a stream of integers using a queue-driven approach with efficient state management.
最近的房间
Find the closest hotel room meeting minimum size requirements using binary search over the valid answer space efficientl…
设计电影租借系统
Implement a movie rental system with efficient search, rent, drop, and report operations using arrays and hash lookups.
股票价格波动
Design an efficient algorithm for managing stock price fluctuations with incorrect and unordered data in a data stream.
将数组分成两个数组并最小化数组和的差
Partition an integer array into two equal halves to minimize the absolute difference of their sums using dynamic program…
序列顺序查询
Track rankings of locations with names and scores, adding new locations and retrieving top-ranked ones efficiently.
统计数组中好三元组数目
Count Good Triplets in an Array requires tracking index orders across two permutations efficiently using binary search.
由单个字符重复的最长子字符串
Solve Longest Substring of One Repeating Character by maintaining mergeable run information under character updates afte…
花期内花的数目
Find the number of flowers in full bloom at the given times for a list of people.
统计区间中的整数数目
Design and implement a data structure to efficiently add intervals and count the total number of integers covered by the…
无限集中的最小数字
Design a data structure to handle the smallest missing element in an infinite set, with the ability to add and remove el…
设计数字容器系统
Learn to implement a Number Container System using hash tables and design techniques to efficiently track numbers and in…
设计食物评分系统
Design a food rating system that tracks and updates ratings of foods, finding the highest rated items by cuisine.
合并相似的物品
Merge Similar Items combines values and weights from two lists, returning the result sorted by value.
删除操作后的最大子段和
Calculate the maximum segment sum after sequential removals using array plus union find for efficient merging of segment…
最长上传前缀
Calculate the longest continuous uploaded prefix in a video stream efficiently using a mix of binary search and data str…
满足不等式的数对数目
Count pairs in two arrays satisfying a given inequality condition using binary search over the valid answer space.
最少翻转操作数
Find the minimum number of operations to move a 1 in an array from a given start position to other positions, considerin…
将数组清空
Solve the "Make Array Empty" problem using binary search to determine the minimum number of operations required.
矩阵中严格递增的单元格数
Find the maximum number of cells that can be visited in a matrix by following strictly increasing values from a starting…
不间断子数组
Count all continuous subarrays efficiently using sliding window with running max-min state tracking for array consistenc…
所有子数组中不平衡数字之和
Learn how to compute the total imbalance across all subarrays by updating gap counts as each subarray expands.
限制条件下元素之间的最小绝对差
Find the minimum absolute difference between two array elements that are at least x indices apart using binary search.
最高频率的 ID
Track the most frequent ID after each update in a dynamic collection of IDs with changing frequencies.
最小化曼哈顿距离
Compute the minimum maximum Manhattan distance by removing one point using array math and geometry insights efficiently.
新增道路查询后的最短距离 II
The problem involves calculating the shortest path from city 0 to city n-1 after each road addition, leveraging greedy c…
设计任务管理器
Design a Task Manager that can efficiently handle task management operations such as adding, editing, executing, and rem…
水果成篮 II
Determine the number of fruit types that remain unplaced after all allocations in the "Fruits Into Baskets II" problem.
水果成篮 III
Fruits Into Baskets III requires placing fruits into baskets efficiently using binary search over the answer space for c…
移除最小数对使数组有序 I
This problem asks for the minimum number of operations to make an array non-decreasing by removing pairs of elements.
设计路由器
Efficiently design a Router class to manage network packets with memory limits using array scanning and hash lookups.
移除最小数对使数组有序 II
The problem asks to find the minimum number of operations to make an array non-decreasing by removing pairs of elements.
第 K 小的路径异或和
This problem involves finding the kth smallest distinct XOR sum for nodes in a subtree of a tree structure using binary-…
电网维护
Determine which power stations remain connected after maintenance using array scanning and hash lookups to track compone…