题库chevron_right分类chevron_right二分查找
search

二分查找

265 道题目
简单: 26中等: 135困难: 104

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

面试场景

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

常见误区

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

练习策略

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

推荐练习顺序

#题目难度
4

寻找两个正序数组的中位数

Find the median of two sorted arrays using binary search for efficient O(log(min(m, n))) time complexity.

困难
33

搜索旋转排序数组

Find the index of a target in a rotated sorted array using a careful binary search that handles pivot shifts.

中等
34

在排序数组中查找元素的第一个和最后一个位置

Locate the first and last index of a target in a sorted array using binary search for precise O(log n) performance.

中等
35

搜索插入位置

Find the correct index for a target value in a sorted array using binary search, or return the position where it should …

简单
69

x 的平方根

Solve the Sqrt(x) problem using binary search to find the integer square root of a number without built-in operators.

简单
74

搜索二维矩阵

Search a 2D matrix efficiently using binary search over its linearized index, ensuring correctness in row-major sorted a…

中等
81

搜索旋转排序数组 II

Determine if a target exists in a rotated sorted array that may contain duplicates using a binary search variation effic…

中等
153

寻找旋转排序数组中的最小值

Find the minimum element in a rotated sorted array using binary search to efficiently identify the point of rotation.

中等
154

寻找旋转排序数组中的最小值 II

Find the minimum in a rotated sorted array with possible duplicates using binary search.

困难
162

寻找峰值

Find Peak Element leverages binary search for efficiently locating a peak in an array, a problem commonly asked in techn…

中等
167

两数之和 II - 输入有序数组

Solve the Two Sum II problem efficiently using binary search over a valid answer space in a sorted array.

中等
209

长度最小的子数组

Find the minimal length of a subarray whose sum is greater than or equal to the target using efficient algorithms.

中等
222

完全二叉树的节点个数

Count Complete Tree Nodes efficiently by leveraging binary-tree traversal, exploiting completeness, and applying bit man…

简单
240

搜索二维矩阵 II

Efficiently search for a target in a 2D matrix using binary search and matrix properties.

中等
268

丢失的数字

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

简单
275

H 指数 II

Compute a researcher's H-Index from a sorted citation array using binary search over the valid answer space efficiently.

中等
278

第一个错误的版本

Find the first bad version of a product using binary search, minimizing the number of API calls.

简单
287

寻找重复数

The problem involves finding the duplicate number in an array of integers, using a binary search approach over the valid…

中等
300

最长递增子序列

Solve the Longest Increasing Subsequence problem using dynamic programming and binary search to efficiently find the sub…

中等
315

计算右侧小于当前元素的个数

Solve the Count of Smaller Numbers After Self problem using binary search and optimized algorithms.

困难
327

区间和的个数

Count the number of subarray sums within a given inclusive range using optimized divide-and-conquer techniques efficient…

困难
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.

简单
352

将数据流变为多个不相交区间

The problem involves designing a class to summarize a data stream of non-negative integers as disjoint intervals using b…

困难
354

俄罗斯套娃信封问题

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

困难
363

矩形区域不超过 K 的最大数值和

Solve the "Max Sum of Rectangle No Larger Than K" problem using binary search over the valid sum space to optimize space…

困难
367

有效的完全平方数

Determine if a given positive integer is a perfect square using a binary search approach over potential square roots eff…

简单
374

猜数字大小

Find the picked number efficiently using binary search while adjusting guesses based on higher or lower feedback in this…

简单
378

有序矩阵中第 K 小的元素

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

中等
400

第 N 位数字

Given n, efficiently find the nth digit in the infinite integer sequence using a binary search over valid positions.

中等
410

分割数组的最大值

Solve the 'Split Array Largest Sum' problem by minimizing the largest sum across k subarrays using dynamic programming a…

困难
441

排列硬币

Determine the maximum number of complete staircase rows possible with n coins using a binary search approach.

简单
456

132 模式

Identify whether a given integer array contains a 132 pattern subsequence using efficient stack and search techniques.

中等
475

供暖器

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

中等
483

最小好进制

Find the smallest good base of an integer n using binary search over the valid answer space.

困难
493

翻转对

Count the number of reverse pairs in a given integer array using efficient algorithms like binary search and merge sort.

困难
497

非重叠矩形中的随机点

Design an algorithm to pick random points within non-overlapping rectangles using binary search and reservoir sampling.

中等
528

按权重随机选择

Random Pick with Weight requires implementing a probabilistic index picker using prefix sums and binary search efficient…

中等
532

数组中的 k-diff 数对

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

中等
540

有序数组中的单一元素

Find the single non-duplicate element in a sorted array where every other element appears exactly twice.

中等
611

有效三角形的个数

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

中等
633

平方数之和

Given a non-negative integer c, determine if there are two integers whose squares sum to c.

中等
658

找到 K 个最接近的元素

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

中等
668

乘法表中第k小的数

Find the kth smallest number in an m x n multiplication table using binary search over the valid answer space.

困难
704

二分查找

Solve the Binary Search problem by finding the index of a target value in a sorted array with O(log n) complexity.

简单
710

黑名单中的随机数

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

困难
713

乘积小于 K 的子数组

Count subarrays with a product strictly less than a given value k using efficient algorithms like binary search and slid…

中等
718

最长重复子数组

Find the maximum length of a subarray that appears in both given integer arrays using dynamic programming.

中等
719

找出第 K 小的数对距离

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

困难
729

我的日程安排表 I

Implement a calendar supporting non-overlapping event bookings using binary search for efficient insertion and conflict …

中等
731

我的日程安排表 II

Implement a calendar that allows double bookings but prevents triple bookings, managing overlapping intervals efficientl…

中等
732

我的日程安排表 III

Implement My Calendar III to track maximum overlapping events efficiently using binary search and segment tree technique…

困难
744

寻找比目标字母大的最小字母

Locate the smallest character in a sorted array that is strictly greater than a given target using efficient binary sear…

简单
754

到达终点数字

Determine the minimum number of moves to reach a target on an infinite number line using step increments, leveraging bin…

中等
778

水位上升的泳池中游泳

Solve the problem of swimming through a grid of rising water with a binary search on the valid answer space.

困难
786

第 K 个最小的质数分数

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

中等
792

匹配子序列的单词数

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

中等
793

阶乘函数后 K 个零

Solve for the number of integers whose factorial ends with a specific number of zeroes using binary search techniques.

困难
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…

中等
852

山脉数组的峰顶索引

Find the peak index in a mountain array using binary search for efficient O(log n) time complexity.

中等
862

和至少为 K 的最短子数组

Find the shortest subarray with a sum of at least k using binary search and sliding window techniques.

困难
875

爱吃香蕉的珂珂

Koko Eating Bananas challenges you to find the minimum eating speed to finish piles of bananas in a given time using bin…

中等
878

第 N 个神奇数字

Find the nth magical number divisible by a or b, using binary search to efficiently handle large inputs.

困难
887

鸡蛋掉落

Solve the Super Egg Drop problem using dynamic programming and binary search to minimize the number of moves required to…

困难
888

公平的糖果交换

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

简单
902

最大为 N 的数字组合

The 'Numbers At Most N Given Digit Set' problem requires calculating how many numbers can be formed using a given digit …

困难
911

在线选举

Solve the Online Election problem by implementing a class that tracks votes and queries the leading candidate at any giv…

中等
981

基于时间的键值存储

Implement a time-based key-value store that retrieves the latest value at a given timestamp using efficient binary searc…

中等
1004

最大连续1的个数 III

Find the longest consecutive ones in a binary array by optimally flipping at most k zeros using sliding window technique…

中等
1011

在 D 天内送达包裹的能力

Find the minimum ship capacity needed to ship all packages within D days, ensuring the cargo is shipped in the given ord…

中等
1027

最长等差数列

Find the length of the longest arithmetic subsequence in a given integer array using scanning and hash-based lookup.

中等
1044

最长重复子串

Find the longest duplicated substring in a string using binary search, sliding window, and rolling hash techniques.

困难
1095

山脉数组中查找目标值

Find in Mountain Array requires locating a target using binary search over a peak-structured array efficiently in intera…

困难
1146

快照数组

Implement a SnapshotArray that efficiently tracks element changes and retrieves past states using array scanning and has…

中等
1157

子数组中占绝大多数的元素

Efficiently find the majority element in any subarray using a data structure optimized for multiple range queries.

困难
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…

困难
1201

丑数 III

Find the nth positive integer divisible by a, b, or c using binary search over the answer space efficiently and accurate…

中等
1208

尽可能使字符串相等

Optimize substring transformations using a binary search approach to maximize the change within a budget.

中等
1235

规划兼职工作

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

困难
1237

找出给定方程的正整数解

Determine all positive integer pairs that satisfy a hidden monotonic function for a given target using binary search ove…

中等
1268

搜索推荐系统

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

中等
1283

使结果不超过阈值的最小除数

Find the smallest divisor such that the sum of all divided array elements is less than or equal to the threshold.

中等
1292

元素和小于等于阈值的正方形的最大边长

This problem challenges you to find the largest square in a matrix with a sum below a given threshold using binary searc…

中等
1300

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

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

中等
1337

矩阵中战斗力最弱的 K 行

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

简单
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 …

中等
1351

统计有序矩阵中的负数

Count Negative Numbers in a Sorted Matrix requires counting negative numbers in a matrix sorted in non-increasing order …

简单
1385

两个数组间的距离值

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

简单
1439

有序矩阵中的第 k 个最小数组和

Find the kth smallest sum in a matrix with sorted rows using binary search and a heap-based approach.

困难
1477

找两个和为目标值且不重叠的子数组

Find two non-overlapping sub-arrays with a given target sum and return the minimal total length efficiently using array …

中等
1482

制作 m 束花所需的最少天数

Determine the minimum number of days required to make m bouquets using k adjacent flowers efficiently with binary search…

中等
1483

树节点的第 K 个祖先

Find the kth ancestor of any node in a tree using efficient binary-tree traversal and dynamic state tracking methods.

困难
1488

避免洪水泛滥

This problem asks you to avoid flooding by deciding when to dry lakes between rain events.

中等
1498

满足条件的子序列数目

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

中等
1508

子数组和排序后的区间和

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

中等
1521

找到最接近目标值的函数值

In this problem, you'll use binary search to find the closest value of a mysterious function to a given target.

困难
1539

第 k 个缺失的正整数

Find the kth missing positive integer in a strictly increasing array using binary search over the answer space efficient…

简单
1552

两球之间的磁力

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

中等
1562

查找大小为 M 的最新分组

Determine the latest step where a contiguous group of ones of exact length m exists using array scanning and hash tracki…

中等
1574

删除最短的子数组使剩余数组有序

Find the shortest subarray to remove in order to make an array non-decreasing using binary search and two-pointer techni…

中等
1608

特殊数组的特征值

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

简单
1631

最小体力消耗路径

Find the minimum effort required to travel from the top-left to the bottom-right of a grid, considering height differenc…

中等
1648

销售价值减少的颜色球

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

中等
1649

通过指令创建有序数组

The problem asks to compute the cost of inserting elements into a sorted array using a series of instructions.

困难
1658

将 x 减到 0 的最小操作数

Find the minimum number of operations to reduce a value x to zero by removing elements from an array.

中等
1671

得到山形数组的最少删除次数

Solve the problem of finding the minimum number of removals to make a given array a mountain array using dynamic program…

困难
1712

将数组分成三个子数组的方案数

The problem requires finding the number of ways to split an array into three subarrays where each split meets a certain …

中等
1713

得到子序列的最少操作次数

Compute the minimum insertions required to transform arr so that target becomes its subsequence using array scanning and…

困难
1739

放置盒子

Optimize the number of boxes touching the floor in a cubic room using binary search to minimize floor occupancy.

困难
1751

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

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

困难
1760

袋子里最少数目的球

Find the minimum penalty (maximum balls in a bag) after performing up to maxOperations to split bags of balls.

中等
1782

统计点对的数目

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

困难
1793

好子数组的最大分数

Maximize the score of a good subarray using binary search to explore the valid answer space with a focus on two-pointer …

困难
1802

有界数组中指定下标处的最大值

Maximize the value at a given index of an array with constraints using binary search over the valid answer space.

中等
1818

绝对差值和

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

中等
1838

最高频元素的频数

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

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

困难
1855

下标对中的最大距离

Find the maximum distance between a pair of values in two non-increasing integer arrays using binary search.

中等
1862

向下取整数对和

The problem asks to calculate the sum of floor divisions for all pairs in a given integer array, using an efficient meth…

困难
1870

准时到达的列车最小时速

This problem asks to find the minimum speed of trains to reach on time using binary search.

中等
1889

装包裹的最小浪费空间

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

困难
1894

找到需要补充粉笔的学生编号

Identify the first student who will run out of chalk using a simulation with prefix sums and binary search.

中等
1898

可移除字符的最大数目

Use binary search and a subsequence check to find the largest removable prefix that still keeps p inside s.

中等
1901

寻找峰值 II

Locate any peak in a 2D matrix using binary search across rows or columns for efficient discovery and verification.

中等
1923

最长公共子路径

The Longest Common Subpath problem requires finding the longest subpath shared by all paths in a graph using binary sear…

困难
1932

合并多棵二叉搜索树

This problem asks you to merge multiple BSTs into a single valid BST by performing a series of operations.

困难
1954

收集足够苹果的最小花园周长

Find the minimum perimeter of a square garden that holds enough apples based on a specific formula involving binary sear…

中等
1964

找出到每个位置为止最长的有效障碍赛跑路线

Compute the longest valid obstacle course at each position using binary search and careful array tracking techniques eff…

困难
1970

你能穿过矩阵的最后一天

Find the last day to walk from top to bottom in a flooded matrix by using binary search and graph traversal techniques.

困难
2008

出租车的最大盈利

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

中等
2009

使数组连续的最少操作数

Find the minimum number of operations to make an array continuous by modifying elements using array scanning and hash lo…

困难
2024

考试的最大困扰度

Maximize the Confusion of an Exam requires adjusting at most k answers to create the longest consecutive true or false s…

中等
2035

将数组分成两个数组并最小化数组和的差

Partition an integer array into two equal halves to minimize the absolute difference of their sums using dynamic program…

困难
2040

两个有序数组的第 K 小乘积

Find the kth smallest product from two sorted arrays using binary search across possible product values efficiently.

困难
2054

两个最好的不重叠活动

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

中等
2055

蜡烛之间的盘子

Determine the number of plates between candles in a given substring using binary search and prefix sum techniques.

中等
2064

分配给商店的最多商品的最小值

Distribute products to stores so the largest store allocation is minimized using binary search over possible maximums.

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

困难
2080

区间内查询数字的频率

Design a data structure to handle efficient frequency queries for subarrays, focusing on hash-based lookups and efficien…

中等
2089

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

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

简单
2106

摘水果

Compute the maximum fruits collectable on an infinite line by moving at most k steps from a start position efficiently.

困难
2111

使数组 K 递增的最少操作次数

This problem requires finding the minimum number of operations to make an array K-increasing using binary search over th…

困难
2141

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

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

困难
2179

统计数组中好三元组数目

Count Good Triplets in an Array requires tracking index orders across two permutations efficiently using binary search.

困难
2187

完成旅途的最少时间

Find the minimum time required for buses to complete at least totalTrips using binary search over time multiples.

中等
2223

构造字符串的总得分和

Calculate the sum of scores of built strings by analyzing longest common prefixes with suffixes in a string using effici…

困难
2226

每个小孩最多能分到多少糖果

Maximize candies allocation for k children by dividing piles into sub-piles using binary search.

中等
2234

花园的最大总美丽值

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

困难
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.

困难
2258

逃离火灾

Maximize the time you can stay at your starting position before moving to safely reach the safehouse while avoiding fire…

困难
2271

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

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

中等
2286

以组为单位订音乐会的门票

Design a ticketing system to allocate concert seats in specific groupings while efficiently handling seat reservations.

困难
2300

咒语和药水的成功对数

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

中等
2302

统计得分小于 K 的子数组数目

Count all non-empty subarrays whose score, defined as sum times length, is strictly less than a given integer k efficien…

困难
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…

中等
2354

优质数对的数目

Calculate the number of excellent pairs in an array using bit counting, hash sets, and efficient pair scanning technique…

困难
2358

分组的最大数量

Determine the maximum number of ordered non-empty student groups for a competition using grades array analysis and binar…

中等
2389

和有限的最长子序列

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

简单
2398

预算内的最多机器人数目

Determine the maximum number of consecutive robots you can operate without exceeding a given budget using efficient bina…

困难
2411

按位或最大的最小子数组长度

Find the smallest subarrays with the maximum bitwise OR for each starting index in an array.

中等
2424

最长上传前缀

Calculate the longest continuous uploaded prefix in a video stream efficiently using a mix of binary search and data str…

中等
2426

满足不等式的数对数目

Count pairs in two arrays satisfying a given inequality condition using binary search over the valid answer space.

困难
2439

最小化数组中的最大值

Minimize Maximum of Array involves finding the smallest possible maximum value after applying a series of operations on …

中等
2448

使数组相等的最小开销

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

困难
2454

下一个更大元素 IV

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

困难
2468

根据限制分割消息

Split Message Based on Limit requires dividing a string into parts with length constraints using a calculated suffix pat…

困难
2476

二叉搜索树最近节点查询

Solve the problem of finding closest nodes in a Binary Search Tree for multiple queries, efficiently handling each query…

中等
2498

青蛙过河 II

Frog Jump II requires finding the minimal maximum jump length for a frog to traverse stones forward and backward efficie…

中等
2501

数组中最长的方波

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

中等
2513

最小化两个数组中的最大值

Minimize the Maximum of Two Arrays requires finding the smallest possible maximum number across two arrays, using binary…

中等
2517

礼盒的最大甜蜜度

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

中等
2528

最大化城市的最小电量

Determine the maximum minimum power a city can achieve by strategically adding power stations using binary search and pr…

困难
2529

正整数和负整数的最大计数

Compute the maximum count between positive and negative integers in a sorted array using efficient binary search countin…

简单
2540

最小公共值

Find the smallest integer appearing in both sorted arrays efficiently using array scanning and hash-based lookup techniq…

简单
2554

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

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

中等
2555

两个线段获得的最多奖品

Maximize the total prizes by choosing two segments of length k on a sorted line of prize positions efficiently using bin…

中等
2560

打家劫舍 IV

House Robber IV requires calculating minimum maximum money the robber can take using state transition dynamic programmin…

中等
2563

统计公平数对的数目

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

中等
2565

最少得分子序列

Find the minimum score of a string by removing characters from t while maintaining subsequence validity with s.

困难
2576

求出最多标记下标

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

中等
2589

完成所有任务的最少时间

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

困难
2594

修车的最少时间

Find the minimum time to repair all cars using mechanics with different ranks, applying binary search over possible time…

中等
2601

质数减法运算

Determine if it's possible to make the array strictly increasing using prime subtractions.

中等
2602

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

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

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

困难
2713

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

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

困难
2736

最大和查询

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

困难
2779

数组的最大美丽值

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

中等
2790

长度递增组的最大数目

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

困难
2812

找出最安全路径

Find the Safest Path in a Grid uses binary search and BFS to maximize path safeness from thieves in a grid.

中等
2817

限制条件下元素之间的最小绝对差

Find the minimum absolute difference between two array elements that are at least x indices apart using binary search.

中等
2824

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

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

简单
2826

将三个组排序

Determine the minimum removals to make an array of 1s, 2s, and 3s non-decreasing using dynamic programming transitions.

中等
2830

销售利润最大化

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

中等
2831

找出最长等值子数组

Find the maximum length of an equal subarray after removing up to k elements using array scanning and hash-based index t…

中等
2856

删除数对后的最小数组长度

This problem involves minimizing the length of a sorted array by repeatedly removing adjacent pairs of equal elements.

中等
2861

最大合金数

Determine the maximum number of alloys possible using limited metal stock and budget, leveraging binary search efficient…

中等
2926

平衡子序列的最大和

Learn to find the maximum sum of a balanced subsequence using dynamic programming and careful state transitions efficien…

困难
2940

找到 Alice 和 Bob 可以相遇的建筑

Determine the leftmost building where Alice and Bob can meet using a binary search over valid move sequences.

困难
2945

找到最大非递减数组的长度

Solve Find Maximum Non-decreasing Array Length with prefix-sum DP transitions that maximize kept segments while preservi…

困难
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…

困难
2970

统计移除递增子数组的数目 I

Count the number of incremovable subarrays in an array by removing them to create a strictly increasing sequence.

简单
2972

统计移除递增子数组的数目 II

Count the number of incremovable subarrays where removal of the subarray results in a strictly increasing array.

困难
2981

找出出现至少三次的最长特殊子字符串 I

Find the longest special substring in a string that appears at least three times, or return -1 if no such substring exis…

中等
2982

找出出现至少三次的最长特殊子字符串 II

Find the longest special substring that occurs at least three times in a given string using binary search and hash table…

中等
3006

找出数组中的美丽下标 I

Identify all beautiful indices where substring a appears and a nearby substring b exists within distance k efficiently.

中等
3007

价值和小于等于 K 的最大数字

Find the greatest number whose accumulated price, based on binary set bit positions, is less than or equal to k.

中等
3008

找出数组中的美丽下标 II

Find Beautiful Indices in the Given Array II challenges you to use binary search and string matching techniques.

困难
3048

标记所有下标的最早秒数 I

The problem asks to determine the earliest second to mark all indices in an array using a set of operations.

中等
3049

标记所有下标的最早秒数 II

This problem asks to determine the earliest second at which all indices in an array can be marked using a sequence of op…

困难
3113

边界元素是最大值的子数组数目

Count the subarrays where the first and last elements are the largest in the subarray, utilizing binary search over vali…

困难
3116

单面值组合的第 K 小金额

Find the kth smallest amount using only one coin denomination at a time, applying binary search efficiently over possibl…

困难
3117

划分数组得到最小的值之和

Solve the problem of dividing an array into subarrays to match specified bitwise AND values using dynamic programming.

困难
3134

找出唯一性数组的中位数

Given a nums array, find the median of its uniqueness array by considering all subarrays and their distinct element coun…

困难
3143

正方形中的最多点数

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

中等
3145

大数组元素的乘积

Solve queries on a massive array of powers of two using binary search to efficiently compute modular products of subarra…

困难
3152

特殊数组 II

Determine whether each subarray meets the special condition of alternating parity for all adjacent elements efficiently …

中等
3161

物块放置查询

Determine if blocks can be placed on an infinite number line using queries, leveraging binary search over the valid answ…

困难
3171

找到按位或最接近 K 的子数组

Find a subarray with bitwise OR closest to a given value k with minimal absolute difference.

困难
3186

施咒的最大总伤害

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

中等
3209

子数组按位与值为 K 的数目

The problem asks to find the number of subarrays with a given AND value in an array, utilizing binary search for optimiz…

困难
3261

统计满足 K 约束的子字符串数量 II

Count Substrings That Satisfy K-Constraint II requires finding valid substrings in a binary string based on a k-constrai…

困难
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…

困难
3291

形成目标字符串需要的最少字符串数 I

Use dynamic programming to split target into the fewest prefixes that match any word prefix, while ruling out dead posit…

中等
3292

形成目标字符串需要的最少字符串数 II

Compute the minimum number of valid strings from an array needed to construct a given target string efficiently using dy…

困难
3296

移山所需的最少秒数

Determine the minimum seconds required to reduce a mountain to zero height using simultaneous workers efficiently.

中等
3312

查询排序后的最大公约数

Solve the Sorted GCD Pair Queries problem by efficiently counting and locating GCDs of all array pairs using hash mappin…

困难
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…

困难
3350

检测相邻递增子数组 II

Find the largest k where two adjacent strictly increasing subarrays of length k exist using binary search techniques.

中等
3356

零数组变换 II

Zero Array Transformation II requires determining the minimum query sequence to convert all array elements to zero using…

中等
3357

最小化相邻元素的最大差值

Minimize the maximum adjacent element difference by filling missing values with two chosen numbers.

困难
3398

字符相同的最短子字符串 I

Minimize the length of the longest substring with identical characters after at most numOps changes in a binary string.

困难
3399

字符相同的最短子字符串 II

Find the minimal length of a substring with identical characters using binary search and controlled character flips effi…

困难
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…

困难
3419

图的最大边权的最小值

Minimize the maximum edge weight in a graph after removing certain edges while ensuring node reachability.

中等
3449

最大化游戏分数的最小值

Maximizing the minimum score after at most m moves, leveraging binary search and greedy strategies over an array of scor…

困难
3453

分割正方形 I

Find the minimum y-coordinate of a horizontal line that balances the areas of squares above and below it.

中等
3454

分割正方形 II

Separate Squares II requires finding the minimum y-coordinate such that squares' areas are split evenly above and below …

困难
3455

最短匹配子字符串

Find the shortest substring in a string that matches a pattern with exactly two wildcards efficiently using binary searc…

困难
3464

正方形上的点之间的最大距离

Select k points on a square boundary to maximize minimum Manhattan distance using binary search and greedy placement str…

困难
3477

水果成篮 II

Determine the number of fruit types that remain unplaced after all allocations in the "Fruits Into Baskets II" problem.

简单
3479

水果成篮 III

Fruits Into Baskets III requires placing fruits into baskets efficiently using binary search over the answer space for c…

中等
3488

距离最小相等元素查询

Find the nearest index with the same value for each query using array scanning combined with hash lookups efficiently.

中等
3501

操作后最大活跃区段数 II

Maximize the number of active sections in a binary string with at most one trade.

困难
3508

设计路由器

Efficiently design a Router class to manage network packets with memory limits using array scanning and hash lookups.

中等
3532

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

Determine if paths exist between nodes using array scanning and hash lookups for efficient component checks in graphs.

中等
3534

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

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

困难
3585

树中找到带权中位节点

Given a weighted tree and queries, find the weighted median node for each path between two nodes using binary-tree trave…

困难
3600

升级后最大生成树稳定性

Maximizing the stability of a spanning tree with upgrades requires careful optimization of edge strengths using binary s…

困难
3605

数组的最小稳定性因子

The problem requires finding the minimum stability factor of an array by utilizing binary search and math-based optimiza…

困难
3608

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

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

中等
3613

最小化连通分量的最大成本

Minimize Maximum Component Cost leverages binary search over edge weights to optimize the cost of graph components after…

中等
3620

恢复网络路径

Find the maximum recovery cost of valid paths in a directed acyclic graph where some nodes are offline.

困难

关联高频模式

LeetCode 二分查找题型题解:265题训练路线