二分/三分/两点法
文章平均质量分 67
_TCgogogo_
这个作者很懒,什么都没留下…
展开
-
LeetCode 1477 Find Two Non-overlapping Sub-arrays Each With Target Sum (滑动窗)
题目分析:像这种求两段不重复的问题很容易想到分别从左往右,从右往左计算答案再枚举中点。题目大意:求两段不重复的和为target的子串的最小长度和。原创 2023-12-28 15:47:18 · 497 阅读 · 0 评论 -
LeetCode 1300 Sum of Mutated Array Closest to Target (前缀和 二分)
Given an integer arrayarrand a target valuetarget, return the integervaluesuch that when we change all the integers larger thanvaluein the given array to be equal tovalue, the sum of the array gets as close as possible (in absolute difference) tot...原创 2022-05-08 17:57:20 · 270 阅读 · 0 评论 -
LeetCode 881 Boats to Save People (两点法)
You are given an arraypeoplewherepeople[i]is the weight of theithperson, and aninfinite number of boatswhere each boat can carry a maximum weight oflimit. Each boat carries at most two people at the same time, provided the sum of the weight of tho...原创 2022-03-09 10:16:05 · 116 阅读 · 0 评论 -
LeetCode 2054 Two Best Non-Overlapping Events (排序 二分)
You are given a0-indexed2D integer array ofeventswhereevents[i] = [startTimei, endTimei, valuei]. Theithevent starts atstartTimeiand ends atendTimei, and if you attend this event, you will receive a value ofvaluei. You can chooseat mosttwonon...原创 2022-02-19 14:59:33 · 385 阅读 · 0 评论 -
LeetCode 1574 Shortest Subarray to be Removed to Make Array Sorted (两点法 + 二分)
Given an integer arrayarr, remove a subarray (can be empty) fromarrsuch that the remaining elements inarrarenon-decreasing.Returnthe length of the shortest subarray to remove.Asubarrayis a contiguous subsequence of the array.Example 1:I...原创 2022-02-14 17:43:22 · 254 阅读 · 0 评论 -
LeetCode 23 Merge k Sorted Lists (分治)
You are given an array ofklinked-listslists, each linked-list is sorted in ascending order.Merge all the linked-lists into one sorted linked-list and return it.Example 1:Input: lists = [[1,4,5],[1,3,4],[2,6]]Output: [1,1,2,3,4,4,5,6]Explanati...原创 2022-01-26 21:24:35 · 208 阅读 · 0 评论 -
LeetCode 792 Number of Matching Subsequences (二分或队列)
Given a stringsand an array of stringswords, returnthe number ofwords[i]that is a subsequence ofs.Asubsequenceof a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative...原创 2021-07-04 22:20:03 · 203 阅读 · 0 评论 -
LeetCode 1838 Frequency of the Most Frequent Element (二分)
Thefrequencyof an element is the number of times it occurs in an array.You are given an integer arraynumsand an integerk. In one operation, you can choose an index ofnumsand increment the element at that index by1.Returnthemaximum possible fr...原创 2021-06-01 23:40:27 · 204 阅读 · 2 评论 -
LeetCode 454 4Sum II (二分)
Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make problem a bit easier, all A, B, C, D have same length ...原创 2018-03-16 13:26:29 · 368 阅读 · 0 评论 -
hihocoder 1684 车队(LIS)
#1684 : 车队时间限制:10000ms单点时限:1000ms内存限制:256MB描述在一条单车道的公路上有N辆汽车行驶,从前向后第i辆车的最高速度是Vi。所有车辆都会尽量保持最高速度行驶。不过由于只有单车道,所以当后方快车追上前方慢车后,无法超车,只能降速跟在慢车后面。 于是经过足够长时间(足够后方快车追上前方慢车)的行驶原创 2018-01-24 13:20:17 · 462 阅读 · 0 评论 -
LeetCode 154 Find Minimum in Rotated Sorted Array II (二分 或 分治)
LeetCode 154 Find Minimum in Rotated Sorted Array II (二分 或 分治)原创 2016-09-25 14:12:27 · 1001 阅读 · 0 评论 -
LeetCode 153 Find Minimum in Rotated Sorted Array (二分)
LeetCode 153 Find Minimum in Rotated Sorted Array (二分)原创 2016-09-25 13:32:18 · 932 阅读 · 0 评论 -
LeetCode 81 Search in Rotated Sorted Array II (二分)
LeetCode 81 Search in Rotated Sorted Array II (二分)原创 2016-09-25 12:45:17 · 969 阅读 · 0 评论 -
LeetCode 11 Container With Most Water (两点法)
Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of lineiis at (i,ai) and (i, 0). Find two...原创 2019-03-21 23:57:18 · 202 阅读 · 0 评论 -
LeetCode 33 Search in Rotated Sorted Array (二分查找 推荐)
LeetCode 33 Search in Rotated Sorted Array (二分查找 推荐)原创 2016-09-07 23:58:22 · 984 阅读 · 0 评论 -
LeetCode 658 Find K Closest Elements (二分)
Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If there is a tie, the smaller elements are always prefe...原创 2018-08-28 16:56:58 · 327 阅读 · 0 评论 -
HDU 6031 Innumerable Ancestors (二分+树上倍增)
Innumerable AncestorsTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1854 Accepted Submission(s): 647 Problem DescriptionThere is ...原创 2018-10-22 14:36:28 · 253 阅读 · 0 评论 -
LeetCode 324. Wiggle Sort II (二分+三分 推荐)
Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]....Example 1:Input: nums = [1, 5, 1, 1, 6, 4]Output: One possible answer is [1, 4, 1, 5, 1, 6]...原创 2019-02-21 02:01:48 · 508 阅读 · 0 评论 -
LeetCode 34 Find First and Last Position of Element in Sorted Array (二分)
Given an array of integersnumssorted in ascending order, find the starting and ending position of a giventargetvalue.Your algorithm's runtime complexity must be in the order ofO(logn).If the...原创 2019-03-25 13:37:47 · 169 阅读 · 0 评论 -
hihocoder 1403 后缀数组一·重复旋律 (后缀数组 + 二分)
时间限制:5000ms单点时限:1000ms内存限制:256MB描述小Hi平时的一大兴趣爱好就是演奏钢琴。我们知道一个音乐旋律被表示为长度为 N 的数构成的数列。小Hi在练习过很多曲子以后发现很多作品自身包含一样的旋律。旋律是一段连续的数列,相似的旋律在原数列可重叠。比如在1 2 3 2 3 2 1 中 2 3 2 出现了两次。小Hi想知道一段旋律中出现次数至少为K次的旋律...原创 2019-08-18 18:43:25 · 175 阅读 · 0 评论 -
hihocoder 1407 后缀数组二·重复旋律2 (后缀数组 + 二分)
时间限制:5000ms单点时限:1000ms内存限制:256MB描述小Hi平时的一大兴趣爱好就是演奏钢琴。我们知道一个音乐旋律被表示为长度为 N 的数构成的数列。小Hi在练习过很多曲子以后发现很多作品自身包含一样的旋律。旋律可以表示为一段连续的数列,相似的旋律在原数列不可重叠,比如在1 2 3 2 3 2 1 中 2 3 2 出现了一次,2 3 出现了两次,小Hi想知道一段旋律...原创 2019-08-19 14:52:22 · 182 阅读 · 0 评论 -
hihocoder 1415 后缀数组三·重复旋律3 (后缀数组 + 二分 经典问题)
时间限制:5000ms单点时限:1000ms内存限制:256MB描述小Hi平时的一大兴趣爱好就是演奏钢琴。我们知道一个音乐旋律被表示为长度为 N 的数构成的数列。小Hi在练习过很多曲子以后发现很多作品中的旋律有共同的部分。旋律是一段连续的数列,如果同一段旋律在作品A和作品B中同时出现过,这段旋律就是A和B共同的部分,比如在abab 在 bababab 和 cabacababc ...原创 2019-08-19 21:57:35 · 155 阅读 · 0 评论 -
LeetCode 540 Single Element in a Sorted Array (二分 推荐)
You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactlyonce. Find this single element that appears only once....原创 2019-09-20 01:25:51 · 178 阅读 · 0 评论 -
POJ 2456 Aggressive cows (二分 基础)
POJ 2456 Aggressive cows (二分 基础)原创 2015-07-16 23:57:37 · 1325 阅读 · 3 评论 -
Leetcode 34 Search for a Range (二分搜索 lower_bound和upper_bound)
Leetcode 34 Search for a Range (二分)原创 2016-08-14 16:11:58 · 1128 阅读 · 0 评论 -
LeetCode 209 Minimum Size Subarray Sum (尺取法)
LeetCode 209 Minimum Size Subarray Sum (尺取法)原创 2016-08-26 09:19:23 · 827 阅读 · 0 评论 -
FZU 2216 The Longest Straight (二分)
FZU 2216 The Longest Straight (二分)原创 2016-08-20 19:42:02 · 577 阅读 · 0 评论 -
BZOJ 2440 完全平方数 (容斥+莫比乌斯反演+二分)
BZOJ 2440 完全平方数 (容斥+莫比乌斯反演+二分)原创 2015-08-04 12:35:14 · 1525 阅读 · 0 评论 -
NOJ 1972 炒股票的女巫璐璐 && NOJ 1974 BRN (浅谈两点法)
NOJ 1972 炒股票的女巫璐璐 && NOJ 1974 BRN (浅谈两点法)原创 2015-02-16 22:13:54 · 1245 阅读 · 0 评论 -
LightOJ 1293 Document Analyzer (map+两点法)
LightOJ 1293 Document Analyzer (map+两点法)原创 2015-04-07 13:46:43 · 918 阅读 · 0 评论 -
CSU 1204 Rectangles (二分)
CSU 1204 Rectangles (二分)原创 2015-08-14 16:33:43 · 880 阅读 · 0 评论 -
POJ 1064 Cable master (二分 分数化整数)
POJ 1064 Cable master (二分 分数化整数)原创 2015-07-16 23:01:23 · 1540 阅读 · 0 评论 -
POJ 2785 4 Values whose Sum is 0 (对半分解 二分搜索)
POJ 2785 4 Values whose Sum is 0 (对半分解 二分搜索)原创 2015-07-27 18:49:02 · 790 阅读 · 0 评论 -
POJ 3233 Matrix Power Series (矩阵快速幂+二分)
POJ 3233 Matrix Power Series (矩阵快速幂+二分)原创 2015-02-18 20:52:37 · 2199 阅读 · 0 评论 -
POJ 3273 Monthly Expense (二分枚举)
经典的二分枚举原创 2015-02-05 13:26:10 · 1314 阅读 · 0 评论 -
POJ 3258 River Hopscotch (二分)
经典的二分题原创 2015-02-06 11:37:00 · 1097 阅读 · 0 评论 -
codeforces 492D Vanya and Computer Game (二分)
D. Vanya and Computer Gametime limit per test2 secondsmemory limit per test256 megabytesVanya and his friend Vova play a computer game where they need to destroyn monsters to pas原创 2015-02-06 00:52:50 · 967 阅读 · 0 评论 -
弱校联萌十一大决战之强力热身 B.Carries (二分 数学)
弱校联萌十一大决战之强力热身 B.Carries (二分 数学)原创 2015-10-08 11:15:03 · 1205 阅读 · 0 评论 -
ZOJ 3908 Number Game (贪心+二分+multiset)
ZOJ 3908 Number Game原创 2015-10-11 19:45:55 · 1098 阅读 · 1 评论 -
HDU 5726 GCD (RMQ + 二分)
HDU 5726 GCD (RMQ + 二分)原创 2016-07-21 11:30:58 · 718 阅读 · 0 评论