题库chevron_right分类chevron_right排序
sort

排序

400 道题目
简单: 81中等: 233困难: 86

排序 是技术面试里最常出现的能力维度之一。建议先掌握基础题型的边界处理,再逐步过渡到模式识别和复杂度 trade-off。

面试场景

高频考察问题建模、边界条件与口头表达的清晰度。

常见误区

只背模板不解释为什么,容易在追问里失分。

练习策略

每轮练 3-5 题,固定复盘复杂度和可替代解法。

推荐练习顺序

#题目难度
15

三数之和

Given an integer array, return all unique triplets where the sum is zero using two-pointer scanning with careful duplica…

中等
16

最接近的三数之和

Find the sum of three integers in an array that is closest to a given target using two-pointer scanning.

中等
18

四数之和

The 4Sum problem requires finding all unique quadruplets in an array that sum to a specific target value.

中等
47

全排列 II

Generate all unique permutations of an array containing duplicates using backtracking and pruning to avoid repeated sequ…

中等
49

字母异位词分组

Group the anagrams in a list of strings using efficient hash table-based methods, focusing on array scanning.

中等
56

合并区间

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

中等
75

颜色分类

Sort Colors requires in-place reordering of an array using a two-pointer scanning strategy to group 0s, 1s, and 2s effic…

中等
88

合并两个有序数组

Merge two sorted arrays into the first array in non-decreasing order, using a two-pointer approach.

简单
147

对链表进行插入排序

Sort a singly linked list using insertion sort by carefully manipulating pointers to maintain a sorted order efficiently…

中等
148

排序链表

Sort List requires sorting a singly linked list efficiently using pointer manipulation and merge sort for optimal perfor…

中等
164

最大间距

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

中等
169

多数元素

Find the majority element in an array, where the element appears more than n/2 times, using efficient algorithms.

简单
179

最大数

The problem asks to arrange integers to form the largest possible number, focusing on greedy algorithms and string handl…

中等
215

数组中的第K个最大元素

Find the kth largest element in an unsorted array using optimal approaches like Quickselect or heaps.

中等
217

存在重复元素

Determine if an integer array contains any duplicate values by efficiently scanning with a hash lookup to ensure fast de…

简单
220

存在重复元素 III

The problem involves finding a pair of indices in an array where the index and value differences are within given limits…

困难
229

多数元素 II

Identify all elements in an integer array appearing more than ⌊ n/3 ⌋ times using efficient array scanning and hash coun…

中等
242

有效的字母异位词

Check if two strings are anagrams using hashing or sorting techniques.

简单
268

丢失的数字

Find the missing number in an array containing distinct numbers in the range [0, n].

简单
274

H 指数

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

中等
295

数据流的中位数

Implement a MedianFinder class that supports adding numbers and finding the median from a data stream.

困难
324

摆动排序 II

Rearrange an array in a way that every odd-indexed element is greater than its adjacent even-indexed elements.

中等
347

前 K 个高频元素

Find the k most frequent elements from an array using efficient algorithms like hashing and sorting.

中等
349

两个数组的交集

Find the intersection of two arrays while ensuring unique elements using efficient array scanning and hash lookups.

简单
350

两个数组的交集 II

Find the intersection of two arrays, accounting for multiple occurrences of the same number.

简单
354

俄罗斯套娃信封问题

Russian Doll Envelopes is a dynamic programming problem that involves finding the longest chain of envelopes that can be…

困难
368

最大整除子集

Find the largest subset of distinct positive integers where every pair satisfies divisibility using state transition dyn…

中等
378

有序矩阵中第 K 小的元素

Find the kth smallest element in a sorted n x n matrix using efficient binary search or heap strategies for optimized me…

中等
389

找不同

Find the Difference involves identifying the additional letter in one string compared to another, emphasizing hash table…

简单
406

根据身高重建队列

Reconstruct a queue based on the given heights and the number of taller people in front, using sorting and binary indexe…

中等
414

第三大的数

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

简单
435

无重叠区间

Determine the minimum number of intervals to remove from a list to ensure no intervals overlap using dynamic programming…

中等
451

根据字符出现频率排序

Sort Characters By Frequency requires counting characters efficiently and rearranging a string in descending frequency o…

中等
452

用最少数量的箭引爆气球

Find the minimum number of arrows needed to burst all balloons by considering greedy choice and invariant validation.

中等
455

分发饼干

Maximize content children by assigning at most one cookie per child using two-pointer scanning and greedy sorting techni…

简单
462

最小操作次数使数组元素相等 II

Find the minimum moves to equalize all array elements using increments or decrements with array and math techniques.

中等
472

连接词

Find concatenated words by using dynamic programming and depth-first search to identify valid words made of other words …

困难
475

供暖器

Determine the minimum heater radius to cover all houses using a binary search over potential radius values efficiently.

中等
502

IPO

Maximize total capital by selecting up to k projects, based on initial capital and project profits using a greedy strate…

困难
506

相对名次

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

简单
522

最长特殊序列 II

Find the longest string in an array that is not a subsequence of any other string, using array scanning and hash checks …

中等
524

通过删除字母匹配到字典里最长单词

Find the longest word in the dictionary that can be formed by deleting characters from a string, using two-pointer scann…

中等
532

数组中的 k-diff 数对

Solve K-diff Pairs in an Array by counting unique differences with a hash map or sorted two-pointer sweep.

中等
539

最小时间差

Calculate the smallest time difference between clock points using array manipulation and mathematical conversions effici…

中等
561

数组拆分

Maximize the sum of minimums of n pairs in a 2n integer array using a greedy pairing strategy efficiently.

简单
581

最短无序连续子数组

Find the shortest unsorted continuous subarray that, if sorted, would sort the entire array.

中等
594

最长和谐子序列

Find the length of the longest harmonious subsequence in an integer array using array scanning and hash-based frequency …

简单
611

有效三角形的个数

Count all triplets in an integer array that satisfy the triangle inequality to form valid triangles efficiently using so…

中等
621

任务调度器

Task Scheduler is solved by counting task frequencies and computing how cooldown gaps force idle slots around the most f…

中等
628

三个数的最大乘积

Find three numbers in an array whose product is the largest using sorting and careful handling of negative values.

简单
630

课程表 III

Solve the 'Course Schedule III' problem with a greedy approach involving course selection and validation of constraints.

困难
632

最小区间

Find the minimal range covering at least one number from each of k sorted lists using array scanning and hash lookup eff…

困难
645

错误的集合

Identify the duplicated and missing numbers in an integer array using array scanning combined with hash table lookup eff…

简单
646

最长数对链

Determine the maximum length of a chain formed by pairs using dynamic programming and greedy sorting techniques efficien…

中等
658

找到 K 个最接近的元素

Identify the k integers closest to a target x in a sorted array using binary search and two-pointer strategies efficient…

中等
692

前K个高频单词

Solve Top K Frequent Words by counting each word, then ordering ties alphabetically so frequency wins before lexicograph…

中等
710

黑名单中的随机数

Random Pick with Blacklist requires designing a method to uniformly pick integers while excluding blacklisted values eff…

困难
719

找出第 K 小的数对距离

Solve Find K-th Smallest Pair Distance by sorting nums, then binary searching the distance and counting valid pairs with…

困难
720

词典中最长的单词

Find the longest word in a dictionary that can be built one character at a time from other words in the dictionary.

中等
721

账户合并

Merge accounts by connecting emails and returning each user's sorted email list using array scanning and hash lookup eff…

中等
726

原子的数量

Compute the exact count of each atom in a chemical formula using stack-based state management and hashing techniques eff…

困难
747

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

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

简单
757

设置交集大小至少为2

Solve the Set Intersection Size At Least Two problem using a greedy approach and invariant validation.

困难
767

重构字符串

Reorganize a string so that no two adjacent characters are the same, if possible, using a greedy approach.

中等
768

最多能完成排序的块 II

Determine the maximum number of chunks you can split an array into so that sorting each chunk results in a fully sorted …

困难
769

最多能完成排序的块

The Max Chunks To Make Sorted problem requires you to split an array into the maximum number of chunks that can be sorte…

中等
786

第 K 个最小的质数分数

Find the k-th smallest fraction from a sorted array of unique primes using a binary search over the answer space.

中等
791

自定义字符串排序

Sort the string `s` according to a custom order defined by string `order`.

中等
792

匹配子序列的单词数

Given a string s and a list of words, count how many words are subsequences of s using efficient array scanning and hash…

中等
823

带因子的二叉树

Given an array of integers, find how many binary trees can be formed such that non-leaf nodes' values are the product of…

中等
825

适龄的朋友

The Friends Of Appropriate Ages problem involves counting valid friend requests between people based on their ages with …

中等
826

安排工作以达到最大收益

Assign workers to jobs maximizing total profit using difficulty, profit, and worker arrays efficiently with binary searc…

中等
833

字符串中的查找与替换

This problem challenges you to perform multiple string replacements at specific indices using a pattern involving array …

中等
846

一手顺子

Check if a hand of cards can be rearranged into groups of consecutive values.

中等
853

车队

The Car Fleet problem asks how many car fleets will reach a target given their starting positions and speeds, considerin…

中等
857

雇佣 K 名工人的最低成本

Find the minimum cost to hire exactly k workers based on quality and wage expectations in this challenging greedy proble…

困难
869

重新排序得到 2 的幂

Determine if a number's digits can be rearranged to form a power of two using counting and hash-based checks.

中等
870

优势洗牌

Maximize the advantage of nums1 over nums2 using a two-pointer greedy strategy, carefully tracking which elements beat o…

中等
881

救生艇

Find the minimum number of boats required to save all people, using a two-pointer approach for efficient pairing.

中等
888

公平的糖果交换

Determine which single candy box Alice and Bob should swap to equalize their total candies using array scanning and hash…

简单
891

子序列宽度之和

Calculate the sum of widths for all subsequences in an integer array using sorting and combinatorial math efficiently.

困难
893

特殊等价字符串组

Determine the number of special-equivalent string groups using character swaps at even or odd indices efficiently.

中等
899

有序队列

Given a string and integer k, rearrange characters to achieve the lexicographically smallest string using limited rotati…

困难
905

按奇偶排序数组

Reorder an integer array so all even numbers come before odd numbers using a precise two-pointer scanning method.

简单
910

最小差值 II

Determine the minimum possible difference between the largest and smallest numbers after adjusting each by plus or minus…

中等
912

排序数组

Sort an array using an optimal algorithm, focusing on time and space complexity considerations.

中等
922

按奇偶排序数组 II

Sort an array where even numbers appear at even indices and odd numbers appear at odd indices using two-pointer scanning…

简单
923

三数之和的多种可能

Count all unique triplets in an integer array whose sum equals the target, handling multiplicity efficiently using hashi…

中等
937

重新排列日志文件

Reorder Data in Log Files requires sorting letter-logs lexicographically while keeping digit-logs in original order for …

中等
939

最小面积矩形

Find the minimum area of a rectangle formed by given points on a 2D plane with sides parallel to axes.

中等
945

使数组唯一的最小增量

This problem challenges you to find the minimum moves to make all elements in an array unique by incrementing elements.

中等
948

令牌放置

Maximize your score in the Bag of Tokens problem by strategically playing tokens with two-pointer scanning and greedy te…

中等
950

按递增顺序显示卡牌

Determine the initial deck order to reveal cards in strictly increasing order using queue-driven simulation logic.

中等
954

二倍数对数组

Given an array of even length, check if it can be reordered to satisfy a specific doubling condition.

中等
969

煎饼排序

Sort an array using pancake flips, leveraging two-pointer scanning and invariant tracking to iteratively position the la…

中等
973

最接近原点的 K 个点

Find the k closest points to the origin in a 2D plane using array operations and Euclidean distance calculations efficie…

中等
975

奇偶跳

Determine the number of valid starting indices in an array where you can reach the end with alternating odd and even jum…

困难
976

三角形的最大周长

Given an integer array, find the largest perimeter of a triangle formed from three of these lengths.

简单
977

有序数组的平方

The problem involves squaring elements of a sorted array and returning the squares in non-decreasing order.

简单
987

二叉树的垂序遍历

Perform a vertical order traversal of a binary tree, sorting nodes by their values within columns.

困难
1005

K 次取反后最大化的数组和

Maximize the sum of an integer array after exactly k negations using a greedy approach and invariant tracking for optima…

简单
1029

两地调度

Two City Scheduling requires selecting optimal city assignments for 2n people to minimize total travel costs efficiently…

中等
1030

距离顺序排列矩阵单元格

Compute all matrix cell coordinates sorted by Manhattan distance from a given center using array and math techniques eff…

简单
1040

移动石子直到连续 II

Determine the minimum and maximum moves to make stones consecutive using sliding window and endpoint adjustments efficie…

中等
1048

最长字符串链

Find the longest word chain by scanning arrays and using hash lookups to efficiently track predecessor-successor sequenc…

中等
1051

高度检查器

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

简单
1054

距离相等的条形码

Rearrange barcodes in an array so that no two adjacent elements are equal, using a greedy approach and hash table for ef…

中等
1090

受标签影响的最大值

Maximize the sum of selected item values while respecting label use limits using array scanning and hash tracking.

中等
1094

拼车

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

中等
1122

数组的相对排序

Sort arr1 by the relative order of arr2, with remaining elements placed in ascending order.

简单
1169

查询无效交易

Detect invalid transactions by scanning arrays and cross-checking with hash tables for time, amount, and city conflicts …

中等
1170

比较字符串最小字母出现频次

Compare Strings by Frequency of the Smallest Character requires counting minimal character frequencies in words and quer…

中等
1187

使数组严格递增

Determine the minimum operations to transform arr1 into a strictly increasing sequence using values from arr2 efficientl…

困难
1200

最小绝对差

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

简单
1202

交换字符串中的元素

Find the lexicographically smallest string by swapping characters in given pairs of indices.

中等
1235

规划兼职工作

Compute the maximum profit from non-overlapping jobs using state transition dynamic programming with sorted arrays and b…

困难
1262

可被三整除的最大和

Find the maximum sum divisible by three from a given array using dynamic programming and state transition.

中等
1268

搜索推荐系统

Design a search suggestion system that provides the top three lexicographically smallest products matching a search word…

中等
1288

删除被覆盖区间

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

中等
1296

划分数组为连续数字的集合

Determine if an integer array can be partitioned into sets of k consecutive numbers using array scanning and hash mappin…

中等
1300

转变数组后最接近目标值的数组和

Find the integer that mutates all larger elements in an array to minimize the sum difference to a target efficiently.

中等
1305

两棵二叉搜索树中的所有元素

Merge elements from two binary search trees and return them sorted in ascending order.

中等
1311

获取你好友已观看的视频

Find videos watched by friends up to a given level and return them sorted by frequency and alphabetically.

中等
1329

将矩阵按对角线排序

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

中等
1331

数组序号转换

Transform the elements of an array into their ranks, where the rank represents the size order of the elements.

简单
1333

餐厅过滤器

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

中等
1337

矩阵中战斗力最弱的 K 行

Find the k weakest rows in a binary matrix where rows contain soldiers and civilians, using sorting and binary search te…

简单
1338

数组大小减半

This problem asks to minimize the set of integers removed to reduce an array's size to at least half by removing occurre…

中等
1340

跳跃游戏 V

Jump Game V is a hard dynamic programming problem that focuses on maximizing jumps between indices in an array.

困难
1346

检查整数及其两倍数是否存在

Solve Check If N and Its Double Exist by scanning once and checking doubles or halves in a hash set.

简单
1348

推文计数

Design an efficient solution to track and retrieve tweet counts over different frequencies using binary search and hash …

中等
1353

最多可以参加的会议数目

Maximize the number of events you can attend given their start and end days using a greedy strategy.

中等
1356

根据数字二进制下 1 的数目排序

Sort an array of integers by the number of 1's in their binary representation and then by their value in case of ties.

简单
1363

形成三的最大倍数

Find the largest number divisible by three by selecting and ordering digits optimally using state transition dynamic pro…

困难
1365

有多少小于当前数字的数字

In this problem, you need to determine how many numbers are smaller than each element in an array, focusing on array sca…

简单
1366

通过投票对团队排名

Rank Teams by Votes requires counting position-based votes and resolving ties with array scanning and hash lookup techni…

中等
1383

最大的团队表现值

Maximize the performance of a team by selecting up to k engineers with the highest performance based on speed and effici…

困难
1385

两个数组间的距离值

Calculate the distance value between two integer arrays by determining how many elements in arr1 don't have a close coun…

简单
1387

将整数按权重排序

Sort integers in a range based on their power value using dynamic programming and memoization, handling ties with ascend…

中等
1402

做菜顺序

Maximize the sum of like-time coefficients by optimally choosing dishes to prepare in this dynamic programming problem.

困难
1403

非递增顺序的最小子序列

Find the minimum subsequence in non-increasing order such that its sum exceeds the sum of non-included elements.

简单
1418

点菜展示表

Generate a restaurant display table from orders by counting each food item per table using array scanning and hash looku…

中等
1424

对角线遍历 II

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

中等
1433

检查一个字符串是否可以打破另一个字符串

This problem checks whether one string can break another using permutations and a greedy approach for comparison.

中等
1451

重新排列句子中的单词

Rearrange words in a sentence by their length, maintaining original order for words of equal size for consistent output.

中等
1460

通过翻转子数组使两个数组相等

Solve Make Two Arrays Equal by Reversing Subarrays by checking whether target and arr contain the same values with match…

简单
1464

数组中两元素的最大乘积

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

简单
1465

切割后面积最大的蛋糕

Maximize the area of a piece of cake after specified horizontal and vertical cuts using greedy algorithms and sorting.

中等
1471

数组中的 k 个最强值

Identify the k strongest values in an array using two-pointer scanning and careful tracking of the array's centre value.

中等
1478

安排邮筒

Allocate k mailboxes to houses along a street minimizing total distance using dynamic programming with state transitions…

困难
1481

不同整数的最少数目

Find the least number of unique integers after removing exactly k elements from an array using efficient frequency count…

中等
1489

找到最小生成树里的关键边和伪关键边

Identify critical and pseudo-critical edges in a weighted graph's minimum spanning tree using Union Find efficiently.

困难
1491

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

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

简单
1498

满足条件的子序列数目

Count all non-empty subsequences in an integer array where the sum of the minimum and maximum elements is at most a targ…

中等
1502

判断能否形成等差数列

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

简单
1508

子数组和排序后的区间和

Compute the sum of sorted subarray sums efficiently using binary search over valid sum ranges and prefix sum accumulatio…

中等
1509

三次操作后最大值与最小值的最小差

Find the minimum difference between the largest and smallest values in an array after performing at most three moves.

中等
1547

切棍子的最小成本

Find the minimum cost to cut a stick into segments at specified positions using dynamic programming and sorting.

困难
1552

两球之间的磁力

Maximize the minimum magnetic force between balls by strategically placing them in baskets using binary search on positi…

中等
1561

你可以获得的最大硬币数目

Solve the Maximum Number of Coins You Can Get using greedy pile selection and invariant validation to maximize your coin…

中等
1585

检查字符串是否可以通过排序子字符串得到另一个字符串

This problem requires checking if string 's' can be transformed into string 't' using substring sort operations.

困难
1589

所有排列中的最大和

Maximize the total sum of requests on nums by greedily assigning larger numbers to most frequently requested indices.

中等
1604

警告一小时内使用相同员工卡大于等于三次的人

Solve LeetCode 1604 by grouping swipe times per employee, sorting each list, and scanning for any three within 60 minute…

中等
1608

特殊数组的特征值

Determine if an array has exactly x elements greater than or equal to x using binary search over the answer space.

简单
1610

可见点的最大数目

Determine the maximum number of points visible from a fixed location within a given angle using a sliding window approac…

困难
1619

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

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

简单
1626

无矛盾的最佳球队

Find the highest score basketball team by choosing players without conflicts in age and score using dynamic programming.

中等
1630

等差子数组

Determine whether subarrays of a given array can be rearranged to form arithmetic sequences using array scanning and has…

中等
1632

矩阵转换后的排名

Compute a unique rank matrix using graph indegree with topological ordering, ensuring each element reflects its relative…

困难
1636

按照频率将数组升序排序

Sort Array by Increasing Frequency requires counting each element and ordering them by frequency, breaking ties with des…

简单
1637

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

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

简单
1647

字符频次唯一的最小删除次数

Determine the minimum deletions needed to ensure all character frequencies in a string are unique using a greedy approac…

中等
1648

销售价值减少的颜色球

Maximize total value by greedily selling diminishing-valued colored balls based on inventory and customer orders.

中等
1657

确定两个字符串是否接近

Check if two strings can transform into each other using letter swaps and frequency reorganizations, leveraging hash tab…

中等
1665

完成所有任务的最少初始能量

Determine the minimum initial energy needed to finish all tasks using a greedy ordering based on required versus actual …

困难
1679

K 和数对的最大数目

Max Number of K-Sum Pairs is a problem involving counting disjoint pairs with a given sum k in an array.

中等
1686

石子游戏 VI

Determine the winner in Stone Game VI using a greedy strategy that accounts for each stone's dual value impact on Alice …

中等
1691

堆叠长方体的最大高度

Maximize the height of stacked cuboids by strategically rotating and stacking them using dynamic programming.

困难
1697

检查边长度限制的路径是否存在

Solve the problem of checking if there exists a path between two nodes under edge length constraints using efficient tec…

困难
1710

卡车上的最大单元数

Maximize total units loaded on a truck by choosing boxes greedily based on highest units per box within truck capacity l…

简单
1727

重新排列后的最大子矩阵

Rearrange columns of a binary matrix to find the largest submatrix of 1s.

中等
1738

找出第 K 大的异或坐标值

Compute the kth largest XOR coordinate in a 2D matrix using prefix sums, bit manipulation, and optimized selection techn…

中等
1751

最多可以参加的会议数目 II

Determine the maximum sum of event values you can collect by attending at most k non-overlapping events using DP.

困难
1755

最接近目标值的子序列和

Find the minimum absolute difference between a target goal and any subsequence sum using optimized dynamic programming a…

困难
1782

统计点对的数目

Given a graph with nodes and edges, count pairs of nodes where the degree sum exceeds a given threshold for each query.

困难
1798

你能构造出连续值的最大数目

Find the maximum number of consecutive integer values starting from zero that can be formed using your coins array.

中等
1818

绝对差值和

Minimize the absolute sum difference between two integer arrays by replacing at most one element from the first array.

中等
1833

雪糕的最大数量

Maximize the number of ice cream bars a boy can buy by applying a greedy choice strategy based on cost sorting.

中等
1834

单线程 CPU

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

中等
1838

最高频元素的频数

Maximize the frequency of an element in an array by incrementing at most `k` elements. Use binary search and greedy tech…

中等
1840

最高建筑高度

Find the maximum building height in a city given height restrictions for specific buildings.

困难
1846

减小和重新排列数组后的最大元素

Determine the maximum value in an array after decreasing elements and rearranging using a greedy invariant approach.

中等
1847

最近的房间

Find the closest hotel room meeting minimum size requirements using binary search over the valid answer space efficientl…

困难
1851

包含每个查询的最小区间

Find the smallest interval containing each query efficiently using binary search.

困难
1859

将句子排序

Reconstruct a shuffled sentence by sorting words using their embedded indices to restore the original sentence order eff…

简单
1877

数组中最大数对和的最小值

Minimize the maximum pair sum in an array by optimally pairing its elements.

中等
1878

矩阵中最大的三个菱形和

Find the three largest distinct rhombus sums from a given grid using array and math techniques.

中等
1887

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

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

中等
1889

装包裹的最小浪费空间

Minimize the wasted space when packaging items into boxes, considering package and box size constraints.

困难
1913

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

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

简单
1921

消灭怪物的最大数量

Eliminate monsters by strategically using a weapon in a video game to stop them before they reach your city.

中等
1943

描述绘画结果

Solve the problem of describing a painted segment with mixed colors using array scanning and hash table lookups.

中等
1968

构造元素不等于两相邻元素平均值的数组

Rearrange an array such that no element equals the average of its neighbors using a greedy approach.

中等
1984

学生分数的最小差值

Minimize the difference between the highest and lowest of k student scores using a sliding window approach.

简单
1985

找出数组中的第 K 大整数

This problem asks to find the kth largest integer in an array of string numbers, highlighting sorting and string-based c…

中等
1996

游戏中弱角色的数量

Identify all weak characters in a game by analyzing attack and defense values using a stack-based greedy sorting approac…

中等
1998

数组的最大公因数排序

The GCD Sort problem challenges you to sort an array using a specific gcd-based swap method.

困难
2007

从双倍数组中还原原数组

Given a shuffled array, determine if it is a doubled array and find the original array.

中等
2008

出租车的最大盈利

Maximize earnings by optimizing taxi ride selection and tips using array scanning, hash lookups, and sorting.

中等
2033

获取单值网格的最小操作数

Determine the fewest additions or subtractions of x to make all grid elements identical using array and math logic.

中等
2037

使每位学生都有座位的最少移动次数

Calculate the minimum total moves to seat each student using greedy assignment and invariant validation efficiently.

简单
2054

两个最好的不重叠活动

Maximize the total value of at most two non-overlapping events using state transition dynamic programming efficiently.

中等
2070

每一个查询的最大美丽值

Determine the maximum beauty of items affordable for each query using efficient binary search and sorting techniques.

中等
2071

你可以安排的最多任务数目

Maximize the number of tasks that can be completed by efficiently using workers and magical pills.

困难
2089

找出数组排序后的目标下标

Find the target indices of a sorted array and return them in increasing order using binary search and sorting techniques…

简单
2092

找出知晓秘密的所有专家

Find all people who receive a secret through meetings using graph traversal with depth-first search efficiently and corr…

困难
2094

找出 3 位偶数

Generate unique 3-digit even numbers from a given array of digits with duplicates.

简单
2099

找到和最大的长度为 K 的子序列

Pick the k largest values, then restore their original order to build the maximum-sum subsequence correctly.

简单
2122

还原原数组

Recover the Original Array helps you understand how to reverse-engineer an array from two subsets using array scanning a…

困难
2126

摧毁小行星

This problem requires destroying asteroids by choosing the right order of collisions based on mass, using a greedy appro…

中等
2135

统计追加字母可以获得的单词数

Given startWords and targetWords, check how many targetWords can be formed by adding one letter and rearranging letters …

中等
2136

全部开花的最早一天

Find the earliest day where all flower seeds are blooming based on their planting and growth times, using a greedy strat…

困难
2141

同时运行 N 台电脑的最长时间

Solve the problem of determining the maximum running time of n computers using a set of batteries.

困难
2144

打折购买糖果的最小开销

Minimize the total cost of buying candies using a greedy approach with a discount system based on candy prices.

简单
2146

价格范围内最高排名的 K 样物品

Use BFS to rank reachable shop items by distance, price, row, and column, then return the best k coordinates.

中等
2148

元素计数

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

简单
2154

将找到的值乘以 2

The "Keep Multiplying Found Values by Two" problem involves repeatedly multiplying a number by two if it is found in an …

简单
2160

拆分数位后四位数字的最小和

Find the minimum sum of two 2-digit numbers by splitting a four-digit number into two integers.

简单
2164

对奇偶下标分别排序

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

简单
2165

重排数字的最小值

Rearrange the digits of an integer to minimize its value while avoiding leading zeros, keeping the sign unchanged.

中等
2171

拿出最少数目的魔法豆

Determine the minimum beans to remove so all remaining non-empty bags have equal beans using a greedy approach.

中等
2191

将杂乱无章的数字排序

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

中等
2195

向数组中追加 K 个整数

In this problem, you need to append k unique positive integers to a given array nums such that the sum is minimized.

中等
2225

找出输掉零场或一场比赛的玩家

Identify players with zero or one losses by efficiently scanning arrays and counting losses using hash lookups for accur…

中等
2231

按奇偶性交换后的最大数字

Maximize a number by swapping digits of the same parity using sorting and priority queue techniques efficiently.

简单
2234

花园的最大总美丽值

Determine the maximum total beauty of gardens by strategically planting flowers using binary search over achievable flow…

困难
2242

节点序列的最大得分

Find the maximum score of a valid node sequence in an undirected graph with given node scores and edges.

困难
2248

多个数组求交集

Find integers that are common across all arrays in a given list of arrays.

简单
2250

统计包含每个点的矩形数目

Given a set of rectangles and points, determine how many rectangles contain each point.

中等
2251

花期内花的数目

Find the number of flowers in full bloom at the given times for a list of people.

困难
2271

毯子覆盖的最多白色砖块数

Solve Maximum White Tiles Covered by a Carpet by sorting intervals, checking optimal carpet starts, and counting full pl…

中等
2273

移除字母异位词后的结果数组

This problem requires removing adjacent anagrams from a list of words using an array scanning and hash lookup approach.

简单
2274

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

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

中等
2279

装满石头的背包的最大数量

Maximize the number of bags filled to capacity by distributing additional rocks using a greedy approach.

中等
2280

表示一个折线图的最少线段数

Determine the fewest lines needed to accurately connect stock price points in a line chart using array and math reasonin…

中等
2285

道路的最大总重要性

Assign unique values to cities to maximize the total importance of all roads using greedy selection based on city connec…

中等
2294

划分数组使最大差为 K

Find the minimum number of subsequences required such that the difference between the maximum and minimum value in each …

中等
2300

咒语和药水的成功对数

Count how many potions pair successfully with each spell using binary search over sorted potion strengths efficiently.

中等
2332

坐上公交的最晚时间

Find the latest time to catch a bus based on departure times, passenger arrivals, and capacity using binary search over …

中等
2333

最小差值平方和

Calculate the minimum sum of squared differences between two arrays using limited modifications and binary search techni…

中等
2335

装满杯子需要的最短总时长

Determine the minimum seconds to fill cups of cold, warm, and hot water using a greedy selection strategy and invariant …

简单
2342

数位和相等数对的最大和

Find the maximum sum of two numbers with equal digit sums in a given array of positive integers.

中等
2343

裁剪数字后查询第 K 小的数字

Solve the Query Kth Smallest Trimmed Number problem by efficiently trimming and sorting strings in an array to answer qu…

中等
2344

使数组可以被整除的最少删除次数

Find the minimum number of deletions to make the smallest element in nums divide all elements of numsDivide.

困难
2357

使数组中所有元素都等于零

Minimize operations to make all array elements zero by subtracting equal amounts in each operation.

简单
2363

合并相似的物品

Merge Similar Items combines values and weights from two lists, returning the result sorted by value.

简单
2386

找出数组的第 K 大和

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

困难
2389

和有限的最长子序列

Find the maximum size of a subsequence from nums with a sum less than or equal to each query value.

简单
2402

会议室 III

Determine which meeting room holds the most meetings by simulating room assignments with precise time tracking.

困难
2406

将区间分为最少组数

Determine the minimum number of non-overlapping groups for a set of intervals using precise two-pointer scanning logic.

中等
2410

运动员和训练师的最大匹配数

Maximize the number of valid player-trainer matchings using two-pointer scanning and careful sorting strategy.

中等
2412

完成所有交易的初始最少钱数

Find the minimum money required to complete all transactions in any order while considering cost and cashback.

困难
2418

按身高排序

Sort the People requires pairing names with heights and sorting them in descending height order efficiently using arrays…

简单
2421

好路径的数目

Count all good paths in a tree by scanning node values and using hash maps to track valid connections efficiently.

困难
2441

与对应负数同时存在的最大正整数

Find the largest positive integer in an array such that its negative counterpart also exists.

简单
2448

使数组相等的最小开销

Find the minimum cost to make all elements of an array equal by using binary search over valid answers.

困难
2449

使数组相似的最少操作次数

Determine the minimum operations to make two arrays similar by adjusting pairs while respecting element frequencies and …

困难
2454

下一个更大元素 IV

Find the second greater integer for each element in an array using binary search and monotonic stack techniques.

困难
2456

最流行的视频创作者

Identify the most popular video creator by summing views and selecting their top-viewed video with array and hash patter…

中等
2463

最小移动总距离

Optimize the total distance traveled by robots to factories using dynamic programming, sorting, and state transitions.

困难
2465

不同的平均值数目

Calculate the number of unique averages formed by repeatedly pairing smallest and largest elements efficiently using has…

简单
2475

数组中不等三元组的数目

Count all triplets in a positive integer array where each element is distinct using scanning and hash lookup efficiently…

简单
2491

划分技能点相等的团队

Divide players into equal skill teams and return the sum of their chemistry, or -1 if impossible.

中等
2497

图中最大星和

Find the maximum star sum in a graph with specific node values and edges, using greedy algorithms to select the optimal …

中等
2500

删除每行中的最大值

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

简单
2501

数组中最长的方波

Find the length of the longest subsequence where each element is a perfect square of its previous one.

中等
2503

矩阵查询可获得的最大分数

Solve the Maximum Number of Points From Grid Queries problem using two-pointer scanning and invariant tracking.

困难
2512

奖励最顶尖的 K 名学生

Calculate top K student scores by scanning reports and using hash tables for positive and negative word lookups efficien…

中等
2517

礼盒的最大甜蜜度

Maximize the tastiness of a candy basket by choosing k candies from a list of candy prices.

中等
2542

最大子序列的分数

Maximize the score of a subsequence by selecting indices based on nums1 and nums2, using a greedy approach and sorting.

中等
2545

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

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

中等
2551

将珠子放入背包中

The "Put Marbles in Bags" problem challenges you to distribute marbles into bags for maximum score difference using gree…

困难
2554

从一个范围内选择最多整数 I

Determine the maximum count of integers from 1 to n avoiding banned numbers while keeping the sum under maxSum.

中等
2563

统计公平数对的数目

Efficiently count all fair pairs in an array using sorting and binary search, focusing on the sum range between lower an…

中等
2567

修改两个元素的最小分数

The problem asks for the minimum score after changing two elements of an array using a greedy approach.

中等
2576

求出最多标记下标

Maximize marked indices in an array by performing allowed operations, applying binary search to find the optimal count e…

中等
2578

最小和分割

Split a positive integer into two parts to minimize their sum using a greedy approach and sorting.

简单
2580

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

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

中等
2583

二叉树中的第 K 大层和

Find the kth largest level sum in a binary tree using level-order traversal and sorting.

中等
2587

重排数组以得到最大前缀分数

Maximize the number of positive prefix sums by rearranging an integer array using a greedy, order-focused strategy.

中等
2589

完成所有任务的最少时间

Determine the minimum active time for a computer to complete all scheduled tasks within their specific time windows effi…

困难
2592

最大化数组的伟大值

Maximize Greatness of an Array requires permuting numbers to exceed original values at most indices efficiently.

中等
2593

标记所有元素后数组的分数

The problem involves marking elements in an array and calculating the score based on adjacent elements.

中等
2597

美丽子集的数目

Count all non-empty subsets of an array where no two numbers have an absolute difference equal to k, using array scannin…

中等
2602

使数组元素全部相等的最少操作次数

Find the minimum number of operations to make all elements in an array equal for each query.

中等
2607

使子数组元素和相等

Solve Make K-Subarray Sums Equal by grouping circular indices with gcd cycles and minimizing each group to its median.

中等
2611

老鼠和奶酪

In 'Mice and Cheese', you must maximize the total reward of two mice eating cheese while respecting their preferences an…

中等
2616

最小化数对的最大差值

Minimize the Maximum Difference of Pairs seeks to optimize the maximum pairwise difference in a set of index pairs from …

中等
2659

将数组清空

Solve the "Make Array Empty" problem using binary search to determine the minimum number of operations required.

困难
2679

矩阵中的和

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

中等
2681

英雄的力量

Calculate the total power of all non-empty hero groups using state transition dynamic programming efficiently with sorti…

困难
2706

购买两块巧克力

Determine the leftover money after buying exactly two chocolates using a greedy selection and sum validation approach.

简单
2708

一个小组的最大实力值

Maximize the strength of a student group by carefully selecting students based on their scores, using dynamic programmin…

中等
2713

矩阵中严格递增的单元格数

Find the maximum number of cells that can be visited in a matrix by following strictly increasing values from a starting…

困难
2731

移动机器人

Calculate total distances between robots moving on a number line while accounting for collisions using array plus braint…

中等
2733

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

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

简单
2736

最大和查询

Find the maximum sum of paired elements from two arrays under query constraints using efficient binary search techniques…

困难
2740

找出分区值

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

中等
2747

统计没有收到请求的服务器数目

Count Zero Request Servers finds the number of servers with zero requests during specific time intervals for a given set…

中等
2751

机器人碰撞

Robot Collisions involves simulating robot movements and handling collisions with stack-based state management.

困难
2766

重新放置石块

Relocate marbles to new positions in an array by simulating moves, and return sorted occupied positions.

中等
2779

数组的最大美丽值

Find the maximum beauty of an array by adjusting elements within a range using binary search and sliding window techniqu…

中等
2780

合法分割的最小下标

Find the minimum index to split an array such that both subarrays have the same dominant element.

中等
2784

检查数组是否是好的

Determine if a given integer array is a permutation of base[n], containing 1 to n-1 once and n twice, using scanning and…

简单
2785

将字符串中的元音字母排序

Sort Vowels in a String requires identifying vowels in a string and rearranging them in ascending order while keeping co…

中等
2790

长度递增组的最大数目

Maximize the number of groups that can be formed with given usage limits, leveraging binary search for optimal solutions…

困难
2809

使数组和小于等于 x 的最少时间

Calculate the minimum seconds to reduce the array sum to at most x using optimal single-time reductions per index effici…

困难
2813

子序列最大优雅度

Maximize elegance of a k-length subsequence from a list of items with profits and categories.

困难
2818

操作使得分最大

Maximize the score by applying operations on a subarray at most k times, utilizing stack-based state management.

困难
2824

统计和小于目标的下标对数目

This problem asks you to count all index pairs in an array whose sum is strictly less than a given target value efficien…

简单
2830

销售利润最大化

Determine the maximum profit a salesman can earn by strategically selecting non-overlapping offers on consecutive houses…

中等
2840

判断通过操作能否让字符串相等 II

Check if two strings can be made equal using operations that swap characters with the same parity.

中等
2860

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

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

中等
2895

最小处理时间

Determine the minimum total processing time by optimally assigning tasks to multiple processors using a greedy approach.

中等
2931

购买物品的最大开销

Maximize spending by carefully choosing the right items across multiple shops over m * n days.

困难
2933

高访问员工

Identify employees with high system access within one-hour periods based on access logs.

中等
2943

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

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

中等
2948

交换得到字典序最小的数组

Solve the problem of making an array lexicographically smallest through element swaps under a limit constraint.

中等
2952

需要添加的硬币的最小数量

Determine the minimum number of coins to add so all values up to target are obtainable using a greedy sum approach.

中等
2966

划分数组并满足最大差限制

Divide an array into subarrays with a maximum element difference under a given threshold using a greedy approach.

中等
2967

使数组成为等数数组的最小代价

Determine the minimum cost to convert an integer array into a palindromic array using allowed element modifications effi…

中等
2968

执行操作使频率分数最大

Maximize the frequency score by applying up to k operations on a sorted array using binary search over valid answer spac…

困难
2971

找到最大周长的多边形

Determine the largest perimeter polygon from a set of side lengths using a greedy approach with invariant validation che…

中等
2973

树中每个节点放置的金币数目

Determine the exact number of coins to place on each tree node using subtree cost products and DFS tracking.

困难
2974

最小数字游戏

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

简单
2996

大于等于顺序前缀和的最小缺失整数

Find the smallest missing integer greater than the sum of the longest sequential prefix in an array.

简单
3010

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

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

简单
3011

判断一个数组是否可以变为有序

Determine if a given array can be sorted using adjacent swaps restricted by equal set bits in binary representation.

中等
3016

输入单词需要的最少按键次数 II

Given a word, find the minimum number of pushes to type it on a remapped keypad using a greedy approach.

中等
3024

三角形类型

Determine the type of triangle from a three-element array using side sums and equality checks efficiently in constant ti…

简单
3025

人员站位的方案数 I

Calculate how many valid pairs of points can be formed on a 2D plane using array and math enumeration techniques efficie…

中等
3027

人员站位的方案数 II

Calculate all valid placements of people on a 2D grid ensuring Alice can fence herself with Bob without enclosing others…

困难
3035

回文字符串的最大数量

The problem focuses on maximizing the number of palindromes that can be formed from a given list of words through specif…

中等
3039

进行操作使字符串为空

Learn how to systematically apply operations on a string using array scanning and hash lookups to reduce it efficiently.

中等
3041

修改数组后最大化数组中的连续元素数目

Solve Maximize Consecutive Elements in an Array After Modification by sorting and using state transition DP on value and…

困难
3068

最大节点价值之和

Solve Find the Maximum Sum of Node Values by tracking XOR gain parity, not by simulating edge operations across the tree…

困难
3074

重新分装苹果

Distribute packs of apples into boxes using a greedy strategy, minimizing the number of boxes selected efficiently and c…

简单
3075

幸福值最大化的选择方案

Maximize the happiness of selected children by choosing the k happiest ones and applying greedy strategies to minimize l…

中等
3080

执行操作标记数组中的元素

Efficiently mark elements in an array based on queries using scanning plus hash lookup to track marked indices and compu…

中等
3081

替换字符串中的问号使分数最小

Minimize the cost of a string with '?' characters by replacing them with letters in lexicographical order while minimizi…

中等
3085

成为 K 特殊字符串需要删除的最少字符数

Minimize deletions to make a string k-special by adjusting character frequencies.

中等
3098

求出所有子序列的能量和

Compute the sum of powers for all subsequences of length k using state transition dynamic programming efficiently.

困难
3102

最小化曼哈顿距离

Compute the minimum maximum Manhattan distance by removing one point using array math and geometry insights efficiently.

困难
3107

使数组中位数等于 K 的最少操作数

The problem involves minimizing operations to make the median of an array equal to a given value k using a greedy approa…

中等
3111

覆盖所有点的最少矩形数目

Find the minimum number of rectangles needed to cover all points, given constraints on width and position.

中等
3132

找出与数组相加的整数 II

Given two arrays nums1 and nums2, determine the integer added to nums1 to make it equal to nums2 after removing two elem…

中等
3143

正方形中的最多点数

Find the maximum number of points inside a valid square centered at the origin using a scanning and hashing approach.

中等
3169

无需开会的工作日

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

中等
3186

施咒的最大总伤害

Calculate the maximum total damage by selectively casting spells while avoiding adjacent power conflicts using array sca…

中等
3194

最小元素和最大元素的最小平均值

Solve the Minimum Average of Smallest and Largest Elements problem using two-pointer scanning to track averages effectiv…

简单
3218

切蛋糕的最小总开销 I

In this problem, you need to minimize the cost of cutting a cake into 1x1 pieces using vertical and horizontal cuts.

中等
3219

切蛋糕的最小总开销 II

Solve Minimum Cost for Cutting Cake II by choosing optimal cuts using a greedy strategy while tracking cost increments p…

困难
3265

统计近似相等数对 I

Count Almost Equal Pairs I involves finding pairs of elements that can be made equal by swapping at most one digit.

中等
3267

统计近似相等数对 II

Count the number of almost equal integer pairs in an array using array scanning and hash lookup efficiently.

困难
3273

对 Bob 造成的最少伤害

Minimize the total damage dealt to Bob using power to eliminate enemies efficiently with greedy approach.

困难
3281

范围内整数的最大得分

Maximize Score of Numbers in Ranges asks to find the maximum score by selecting integers within given intervals with a f…

中等
3288

最长上升路径的长度

Determine the maximum length of an increasing path in a 2D array using binary search over potential path lengths efficie…

困难
3301

高度互不相同的最大塔高和

Assign heights to towers ensuring each height is unique and the total sum is maximized using greedy sorting techniques.

中等
3319

第 K 大的完美二叉子树的大小

Find the size of the kth largest perfect subtree in a binary tree using tree traversal and state tracking.

中等
3346

执行操作后元素的最高频率 I

Maximize the frequency of an element in an array after performing a series of operations to find the best possible resul…

中等
3347

执行操作后元素的最高频率 II

Determine the maximum frequency of any element after performing limited operations using binary search and sliding windo…

困难
3362

零数组变换 III

Zero Array Transformation III requires removing the minimum number of queries to make all elements zero using greedy val…

中等
3365

重排子字符串以形成目标字符串

Determine if s can be split into k equal substrings and rearranged to match t using a hash table for frequency tracking.

中等
3380

用点构造面积最大的矩形 I

Find the maximum area of a rectangle formed by given points on a plane with unique coordinates.

中等
3382

用点构造面积最大的矩形 II

Find the largest rectangle on a plane using given points while avoiding any interior points and optimizing with math and…

困难
3394

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

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

中等
3397

执行操作后不同元素的最大数量

Maximize distinct elements in an array by performing at most one operation on each element.

中等
3413

收集连续 K 个袋子可以获得的最多硬币数量

Solve the problem of maximizing coins from selecting k consecutive bags, using binary search and sliding window techniqu…

中等
3414

不重叠区间的最大得分

Maximize the score of up to 4 non-overlapping intervals, considering their weight and ensuring no overlap between chosen…

困难
3424

将数组变相同的最小代价

Minimize cost to make arrays identical by performing operations with given constraints and a greedy strategy.

中等
3428

最多 K 个元素的子序列的最值之和

Find the sum of the maximum and minimum elements of subsequences with at most k elements, using dynamic programming.

中等
3433

统计用户被提及情况

Calculate how many times each user is mentioned across MESSAGE events, accounting for offline and online statuses effici…

中等
3446

按对角线进行矩阵排序

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

中等
3457

吃披萨

Maximize the total weight gained by optimally eating pizzas in groups of four using greedy selection and invariant valid…

中等
3458

选择 K 个互不重叠的特殊子字符串

Determine if k non-overlapping special substrings exist in a string using dynamic programming and careful substring trac…

中等
3462

提取至多 K 个元素的最大总和

Find the maximum sum by selecting at most k elements from a 2D matrix respecting per-row limits using a greedy strategy.

中等
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…

中等
3517

最小回文排列 I

Build the smallest palindrome by sorting the left half counts and mirroring them around the optional middle character.

中等
3531

统计被覆盖的建筑

Determine how many buildings in an n x n city are completely surrounded using array scanning and hash lookup efficiently…

中等
3534

针对图的路径存在性查询 II

Solve path existence queries in a graph using binary search on the answer space, focusing on sorted nodes and maximum di…

困难
3536

两个数字的最大乘积

Find the highest product obtainable from any two digits of a given positive integer using math and sorting techniques ef…

简单
3545

不同字符数量最多为 K 时的最少删除数

You need to delete characters in a string to reduce its distinct characters to at most k.

简单
3547

图中边值的最大和

Maximize the sum of edge values in a connected graph by assigning unique node values and optimizing edge products.

困难
3551

数位和排序需要的最小交换次数

Calculate the minimum swaps to sort an array by digit sum, ensuring correct order with tiebreaker values for efficiency.

中等
3556

最大质数子字符串之和

Compute the sum of the three largest unique primes from all substrings using hash table plus math efficiently.

中等
3567

子矩阵的最小绝对差

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

中等
3572

选择不同 X 值三元组使 Y 值之和最大

Select three distinct x-values from arrays to maximize the sum of their corresponding y-values efficiently using hashing…

中等
3606

优惠券校验器

The Coupon Code Validator problem requires filtering and sorting coupons based on specific criteria for validity.

简单
3608

包含 K 个连通分量需要的最小时间

Find the minimum time to remove edges such that a graph with n nodes has at least k connected components.

中等

关联高频模式

LeetCode 排序题型题解:400题训练路线