面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
天际线问题
The Skyline Problem requires calculating a city's silhouette using array manipulation and divide-and-conquer techniques …
区域和检索 - 数组可修改
Implement a mutable range sum query using efficient design patterns to handle multiple updates and range sum queries.
计算右侧小于当前元素的个数
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…
根据身高重建队列
Reconstruct a queue based on the given heights and the number of taller people in front, using sorting and binary indexe…
翻转对
Count the number of reverse pairs in a given integer array using efficient algorithms like binary search and merge sort.
最长递增子序列的个数
This problem challenges you to find the number of longest increasing subsequences in a given array of integers.
掉落的方块
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.
子数组中占绝大多数的元素
Efficiently find the majority element in any subarray using a data structure optimized for multiple range queries.
统计作战单位数
Count the number of valid three-soldier teams using ratings with a state transition dynamic programming approach efficie…
最多 K 次交换相邻数位后得到的最小整数
Reorder digits using at most k adjacent swaps to produce the smallest possible integer, leveraging greedy selection effi…
找到最接近目标值的函数值
In this problem, you'll use binary search to find the closest value of a mysterious function to a given target.
奇妙序列
Implement a Fancy sequence supporting append, addAll, and multAll operations efficiently using cumulative math design te…
通过指令创建有序数组
The problem asks to compute the cost of inserting elements into a sorted array using a series of instructions.
从仓库到码头运输箱子
Optimize the minimum number of trips to deliver boxes to ports under strict ship constraints using dynamic programming t…
区间内查询数字的频率
Design a data structure to handle efficient frequency queries for subarrays, focusing on hash-based lookups and efficien…
统计数组中好三元组数目
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…
统计区间中的整数数目
Design and implement a data structure to efficiently add intervals and count the total number of integers covered by the…
以组为单位订音乐会的门票
Design a ticketing system to allocate concert seats in specific groupings while efficiently handling seat reservations.
最长递增子序列 II
Determine the longest increasing subsequence in an array where consecutive elements differ by at most k using dynamic pr…
最长上传前缀
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.
更新数组后处理求和查询
Solve the Handling Sum Queries After Update problem using arrays and segment trees with lazy propagation for efficiency.
将数组清空
Solve the "Make Array Empty" problem using binary search to determine the minimum number of operations required.
最大和查询
Find the maximum sum of paired elements from two arrays under query constraints using efficient binary search techniques…
子数组不同元素数目的平方和 II
Compute the sum of squares of distinct elements in all subarrays using state transition dynamic programming efficiently.
平衡子序列的最大和
Learn to find the maximum sum of a balanced subsequence using dynamic programming and careful state transitions efficien…
找到 Alice 和 Bob 可以相遇的建筑
Determine the leftmost building where Alice and Bob can meet using a binary search over valid move sequences.
将元素分配到两个数组中 II
Distribute elements into two arrays based on conditions, utilizing a Binary Indexed Tree for efficient counting and simu…
划分数组得到最小的值之和
Solve the problem of dividing an array into subarrays to match specified bitwise AND values using dynamic programming.
物块放置查询
Determine if blocks can be placed on an infinite number line using queries, leveraging binary search over the valid answ…
不包含相邻元素的子序列的最大和
Compute the maximum sum of a subsequence where no two adjacent elements are selected after each array update efficiently…
找到按位或最接近 K 的子数组
Find a subarray with bitwise OR closest to a given value k with minimal absolute difference.
数组中的峰值
Determine peaks in a dynamic integer array using efficient Binary Indexed Tree updates and range queries for fast result…
子数组按位与值为 K 的数目
The problem asks to find the number of subarrays with a given AND value in an array, utilizing binary search for optimiz…
形成目标字符串需要的最少字符串数 I
Use dynamic programming to split target into the fewest prefixes that match any word prefix, while ruling out dead posit…
形成目标字符串需要的最少字符串数 II
Compute the minimum number of valid strings from an array needed to construct a given target string efficiently using dy…
用点构造面积最大的矩形 I
Find the maximum area of a rectangle formed by given points on a plane with unique coordinates.
用点构造面积最大的矩形 II
Find the largest rectangle on a plane using given points while avoiding any interior points and optimizing with math and…
删除所有值为某个元素后的最大子数组和
Maximize Subarray Sum After Removing All Occurrences of One Element involves finding the optimal subarray sum with one a…
统计 K 次操作以内得到非递减子数组的数目
This problem asks you to count non-decreasing subarrays in a given array after applying at most k operations.
分割正方形 II
Separate Squares II requires finding the minimum y-coordinate such that squares' areas are split evenly above and below …
水果成篮 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…
删除一个冲突对后最大子数组数目
Maximize the count of subarrays after removing one conflicting pair using array traversal and segment tree logic efficie…
操作后最大活跃区段数 II
Maximize the number of active sections in a binary string with at most one trade.
带权树中的最短路径
Solve the Shortest Path in a Weighted Tree using binary-tree traversal and efficient state tracking for queries.
求出数组的 X 值 II
The "Find X Value of Array II" problem requires calculating the number of ways to remove a suffix from an array such tha…
分割数组后不同质数的最大数目
Compute the maximum number of distinct prime numbers after sequentially updating array elements with efficient preproces…
数组的最小稳定性因子
The problem requires finding the minimum stability factor of an array by utilizing binary search and math-based optimiza…
位计数深度为 K 的整数数目 II
This problem challenges you to efficiently calculate the number of integers with popcount-depth equal to K using array a…