题库chevron_right数组·排序

数组·排序 模式

42 道题目

模式页适合用来建立可复用解题框架。先识别题目特征,再按固定流程解释状态定义、转移和边界。

识别信号

  • Checks if you sort intervals before merging, as failing to sort leads to incorrect merges.
  • Looks for a clean in-place or linear pass after sorting, showing understanding of array traversal and comparison.
  • Expect discussion on linear time sorting alternatives like bucket sort or radix sort.

解题流程

  1. 1. 明确窗口/状态定义
  2. 2. 更新状态并维护约束
  3. 3. 用边界样例验证

常见失分点

  • Failing to sort intervals first, causing incorrect overlap detection.
  • Sorting the array normally violates the linear time constraint and may be penalized.
  • Miscounting papers with exactly h citations or assuming strict greater-than.

推荐题单梯度

#题目难度
56

合并区间

Merge Intervals requires sorting an array of interval pairs and combining overlaps efficiently using sequential comparis…

中等
164

最大间距

Find the largest difference between successive elements in a sorted array efficiently using linear time techniques and b…

中等
274

H 指数

Determine a researcher's h-index by analyzing citations using array sorting and counting techniques efficiently and accu…

中等
414

第三大的数

Find the third distinct maximum number in an array using array traversal and sorting techniques, handling duplicates car…

简单
506

相对名次

Solve Relative Ranks by sorting scores with original indices, then writing medal labels or numeric places back in answer…

简单
747

至少是其他数字两倍的最大数

Determine if the largest number in the array is at least twice as large as every other element, and return its index or …

简单
1051

高度检查器

Determine how many students are out of place in a line by comparing their heights to the sorted expected order efficient…

简单
1094

拼车

Determine if a car can handle multiple trips without exceeding its capacity using array sorting and event simulation tec…

中等
1200

最小绝对差

Find all pairs with the minimum absolute difference between two elements in an array, and return them in ascending order…

简单
1288

删除被覆盖区间

Remove all intervals fully covered by another using sorting and linear traversal, counting only distinct remaining inter…

中等
1329

将矩阵按对角线排序

Sort each diagonal of a matrix in ascending order, applying sorting and matrix traversal techniques.

中等
1333

餐厅过滤器

Filter restaurants by vegan-friendly status, price, and distance, and sort them by rating and ID.

中等
1424

对角线遍历 II

Traverse a jagged 2D array diagonally by grouping elements with equal row and column sums efficiently using sorting and …

中等
1464

数组中两元素的最大乘积

Find the maximum product of two elements in an array by carefully selecting indices and leveraging sorting for efficienc…

简单
1491

去掉最低工资和最高工资后的工资平均值

Calculate the average salary of employees, excluding the highest and lowest salaries, from an array of unique salaries.

简单
1502

判断能否形成等差数列

Determine if a given array can be rearranged into a valid arithmetic progression using sorting and consecutive differenc…

简单
1619

删除某些元素后的数组均值

Calculate the trimmed mean by removing the lowest and highest 5% of elements in an array using sorting for accuracy and …

简单
1637

两点之间不包含任何点的最宽垂直区域

Find the maximum width of a vertical area between points with no points inside using array sorting efficiently.

简单
1834

单线程 CPU

Simulate task processing with a single-threaded CPU by sorting and prioritizing tasks based on arrival and processing ti…

中等
1887

使数组元素相等的减少操作次数

Find the minimum number of operations to make all array elements equal by reducing the largest elements to the next smal…

中等
1913

两个数对之间的最大乘积差

Find the maximum product difference between two pairs in an integer array using sorting for optimal selection.

简单
2148

元素计数

Count elements in an array that have both strictly smaller and strictly greater numbers using array sorting efficiently.

简单
2164

对奇偶下标分别排序

Rearrange a 0-indexed array by sorting even and odd indices independently for predictable order and correctness.

简单
2191

将杂乱无章的数字排序

Sort numbers based on a custom mapping of their digits, leveraging array manipulation and sorting techniques.

中等
2274

不含特殊楼层的最大连续楼层数

Find the maximum sequence of consecutive floors without any special floors using array sorting techniques efficiently.

中等
2386

找出数组的第 K 大和

Find the K-Sum of an Array requires computing the kth largest subsequence sum in an array using sorting and heap techniq…

困难
2500

删除每行中的最大值

Calculate the total of removed maximum values from each row of a matrix, iterating until all columns are deleted efficie…

简单
2545

根据第 K 场考试的分数排序

Sort a matrix of student scores by the kth exam efficiently using array manipulation and custom sorting techniques.

中等
2580

统计将重叠区间合并成组的方案数

Count Ways to Group Overlapping Ranges is a medium difficulty problem focused on array manipulation and sorting to count…

中等
2679

矩阵中的和

Calculate the maximum score by repeatedly removing the largest elements from each row of a 2D matrix efficiently using s…

中等
2733

既不是最小值也不是最大值

Find a number in an array that is neither the minimum nor maximum value, or return -1 if no such number exists.

简单
2740

找出分区值

Find the minimum partition value by dividing a positive integer array into two subarrays using sorting for efficiency.

中等
2860

让所有学生保持开心的分组方法数

The Happy Students problem asks how many ways a teacher can select a group of students so everyone is happy, based on ce…

中等
2943

最大化网格图中正方形空洞的面积

Learn how to maximize the area of a square-shaped hole by selectively removing horizontal and vertical bars efficiently …

中等
2974

最小数字游戏

The Minimum Number Game involves simulating moves by Alice and Bob on an array, sorting elements and appending them to a…

简单
3010

将数组分成最小总代价的子数组 I

Divide an array into three contiguous subarrays with minimum cost by leveraging array and sorting principles.

简单
3169

无需开会的工作日

Count Days Without Meetings is a problem where you need to count days without scheduled meetings in a given work period.

中等
3394

判断网格图能否被切割成块

Determine if an n x n grid can be divided with two horizontal or vertical cuts using rectangle ranges efficiently.

中等
3446

按对角线进行矩阵排序

Sort Matrix by Diagonals groups cells by diagonal, then sorts bottom-left diagonals descending and top-right diagonals a…

中等
3467

将数组按照奇偶性转化

Transform an array by sorting even numbers first, followed by odd numbers.

简单
3478

选出和最大的 K 个元素

Choose K Elements With Maximum Sum involves sorting and selecting elements based on a specific rule, applying array plus…

中等
3567

子矩阵的最小绝对差

Find the minimum absolute difference in each k x k submatrix within a given 2D grid using array and sorting techniques.

中等

关联题型

LeetCode 数组·排序模式题解:42题训练路线