题库chevron_right数组·driven

数组·driven 模式

54 道题目

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

识别信号

  • Look for efficiency in finding the insertion point, particularly using binary search for the best performance.
  • Evaluate the candidate's understanding of merging intervals and their ability to handle edge cases such as no overlaps or full array merges.
  • Checks the candidate's ability to optimize array traversal.

解题流程

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

常见失分点

  • Failing to consider edge cases such as inserting an interval that doesn't overlap with any existing ones.
  • Failing to handle single-element ranges correctly.
  • Forgetting to update the maximum after the last element if the array ends with 1s.

推荐题单梯度

#题目难度
57

插入区间

Given a sorted array of non-overlapping intervals, insert a new interval and merge any overlapping intervals.

中等
228

汇总区间

Summary Ranges involves converting a sorted array of unique integers into a minimal list of range strings.

简单
485

最大连续 1 的个数

Find the maximum sequence of consecutive 1s in a binary array using an efficient array-driven scanning approach.

简单
665

非递减数列

Check if an array can become non-decreasing by modifying at most one element using an array-driven solution strategy.

中等
674

最长连续递增序列

Find the length of the longest continuous increasing subsequence in an unsorted integer array using an array-driven solu…

简单
717

1 比特与 2 比特字符

Determine whether the last character in a binary array represents a one-bit character or a two-bit character.

简单
849

到最近的人的最大距离

Determine the seat placement that maximizes distance to the nearest person using a linear array scan strategy efficientl…

中等
896

单调数列

Determine if an integer array is entirely monotone increasing or decreasing using a clear array-driven approach.

简单
915

分割数组

Partition the array into two subarrays such that the left contains the smallest possible elements and the right contains…

中等
941

有效的山脉数组

The 'Valid Mountain Array' problem requires determining if an array meets the conditions of a valid mountain array using…

简单
1184

公交站间的距离

Compute the minimal distance between two bus stops on a circular route using an array-driven solution approach.

简单
1287

有序数组中出现次数超过25%的元素

Identify the integer occurring more than 25% in a sorted array using a precise array-driven search strategy for efficien…

简单
1299

将每个元素替换为右侧最大元素

Replace every element in an array with the greatest element on its right side, and replace the last element with -1.

简单
1313

解压缩编码列表

Decompress a run-length encoded list by expanding each pair into repeated values based on frequency.

简单
1375

二进制字符串前缀一致的次数

Count how many times a 1-indexed binary string becomes prefix-aligned as bits are flipped sequentially using an array-dr…

中等
1431

拥有最多糖果的孩子

Determine which kids, after receiving extra candies, will have the greatest number of candies in a group.

简单
1437

是否所有 1 都至少相隔 k 个元素

Check if all 1's in a binary array are at least k places away from each other.

简单
1450

在既定时间做作业的学生人数

Count the number of students doing homework at a given time using an array-driven solution approach.

简单
1470

重新排列数组

Shuffle the Array requires an efficient approach to rearrange elements using an array-driven solution strategy with two …

简单
1550

存在连续三个奇数的数组

Determine if an integer array contains three consecutive odd numbers using a direct array-driven solution strategy for f…

简单
1725

可以形成最大正方形的矩形数目

Determine how many rectangles can be trimmed to form the largest possible square using an array-driven solution strategy…

简单
1752

检查数组是否经排序和轮转得到

Determine if a given integer array is sorted in non-decreasing order and then rotated, handling duplicates correctly.

简单
1779

找到最近的有相同 X 或 Y 坐标的点

Find the nearest point with the same x or y coordinate using Manhattan distance. Return its index or -1 if none exists.

简单
1800

最大升序子数组和

Solve Maximum Ascending Subarray Sum by scanning once, extending rising runs, and resetting the running sum at each drop…

简单
1848

到目标元素的最小距离

Solve Minimum Distance to the Target Element by scanning the array and tracking the smallest distance from start.

简单
1909

删除一个元素使数组严格递增

Determine if removing a single element from an array can make it strictly increasing, using a careful index check approa…

简单
2012

数组美丽值求和

Calculate the sum of beauty for array elements using prefix and suffix tracking to optimize evaluation across indices ef…

中等
2016

增量元素之间的最大差值

Find the maximum difference between two increasing elements in an array using a linear scan to track the minimum value e…

简单
2057

值相等的最小索引

Find the smallest index where the index mod 10 equals the value at that index in the given array.

简单
2155

分组得分最高的所有下标

Find all indices in a binary array where division score is maximized.

中等
2176

统计数组中相等且可以被整除的数对

Given an array, count pairs of elements that are equal and their indices product is divisible by a given integer.

简单
2210

统计数组中峰和谷的数量

Count Hills and Valleys in an Array determines the number of hills and valleys in a given array by analyzing index neigh…

简单
2239

找到最接近 0 的数字

Identify the number in an integer array that is closest to zero, returning the larger one if tied.

简单
2432

处理用时最长的那个任务的员工

Identify which employee spent the longest time on a task using an array-driven approach, analyzing each log entry effici…

简单
2644

找出可整除性得分最大的整数

Determine the divisor with the highest count of divisible elements in an array using a clear array-driven strategy.

简单
2672

有相同颜色的相邻元素数目

Calculate the number of adjacent elements sharing the same color after sequentially updating an initially zeroed array u…

中等
2798

满足目标工作时长的员工数目

Determine how many employees reach the required work hours using a direct array-driven counting approach.

简单
2855

使数组成为递增数组的最少右移次数

Determine the minimum number of right shifts to sort a distinct integer array or return -1 if impossible using array ana…

简单
2873

有序三元组中的最大值 I

Find the maximum value of a triplet in an array where indices follow the order i < j < k.

简单
2874

有序三元组中的最大值 II

Solve Maximum Value of an Ordered Triplet II in linear time by tracking the best left difference and right multiplier.

中等
2908

元素和最小的山形三元组 I

Find the minimum sum of a mountain triplet in an array of integers, or return -1 if no valid triplet exists.

简单
2909

元素和最小的山形三元组 II

Find the minimum sum of a valid mountain triplet in an integer array, or return -1 if no valid triplet exists.

中等
3000

对角线最长的矩形的面积

Find the rectangle with the longest diagonal in a 2D array and return its area, prioritizing maximum area on ties.

简单
3065

超过阈值的最少操作数 I

Count how many numbers are below k, because each such value must be removed in Minimum Operations to Exceed Threshold Va…

简单
3105

最长的严格递增或递减子数组

Find the longest subarray in a given array that is either strictly increasing or strictly decreasing.

简单
3131

找出与数组相加的整数 I

Find the integer added to nums1 to make it equal to nums2 using an array-driven strategy.

简单
3151

特殊数组 I

Determine if an array is special by checking alternating parity for every adjacent pair in linear time.

简单
3285

找到稳定山的下标

Find the indices of stable mountains in an array of mountain heights based on a threshold.

简单
3349

检测相邻递增子数组 I

Check if an array contains two adjacent strictly increasing subarrays of length k using an array-driven approach efficie…

简单
3386

按下时间最长的按钮

Determine which button a child pressed the longest using an array-driven strategy to track time differences efficiently.

简单
3392

统计符合条件长度为 3 的子数组数目

Determine how many subarrays of length three satisfy a sum condition on their first and third elements in an array.

简单
3423

循环数组中相邻元素的最大差值

Find the maximum absolute difference between adjacent elements in a circular array using a straightforward array-driven …

简单
3452

好数字之和

The problem asks for the sum of all good numbers in an array based on specific conditions of neighboring elements.

简单
3502

到达每个位置的最小费用

Calculate the minimum swap costs to reach each position in a line using a precise array-driven strategy for efficiency.

简单

关联题型

LeetCode 数组·driven模式题解:54题训练路线