![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
二分法
Haskei
这个作者很懒,什么都没留下…
展开
-
[Leetcode] 287. Find the Duplicate Number (二分法)
287.Find the Duplicate Number (题目链接) Medium Given an arraynumscontainingn+ 1 integers where each integer is between 1 andn(inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the du...原创 2020-08-04 16:56:36 · 112 阅读 · 0 评论 -
[Lintcode] 183. Wood Cut
183.Wood Cut (题目链接) Given n pieces of wood with lengthL[i](integer array). Cut them into small pieces to guarantee you could have equal or more than k pieces with the same length. What is the longest length you can get from the n pieces of wood? Given ...原创 2020-08-04 12:56:43 · 177 阅读 · 0 评论 -
[Leetcode] 302. Smallest Rectangle Enclosing Black Pixels (暴力/ 二分法)
302.Smallest Rectangle Enclosing Black Pixels (题目链接) Hard An image is represented by a binary matrix with0as a white pixel and1as a black pixel. The black pixels are connected, i.e., there is only one black region. Pixels are connected horizont...原创 2020-08-03 11:51:41 · 235 阅读 · 0 评论 -
[Leetcode] 81. Search in Rotated Sorted Array II (在包含重复元素的数组中寻找某一个数)
81.Search in Rotated Sorted Array II (题目链接) Medium Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e.,[0,0,1,2,2,5,6]might become[2,5,6,0,0,1,2]). You are given a target value to search. If found in...原创 2020-08-03 07:48:56 · 124 阅读 · 0 评论 -
[Leetcode] 162. Find Peak Element (直接求/二分法)
162.Find Peak Element(题目链接) Medium A peak element is an element that is greater than its neighbors. Given an input arraynums, wherenums[i] ≠ nums[i+1], find a peak element and return its index. The array may contain multiple peaks, in that case retu...原创 2020-08-01 12:11:24 · 175 阅读 · 0 评论 -
[Leetcode] 153. Find Minimum in Rotated Sorted Array (二分法)
153.Find Minimum in Rotated Sorted Array(题目链接) Medium Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7]might become [4,5,6,7,0,1,2]). Find the minimum element. You may assume no d...原创 2020-08-01 11:55:19 · 108 阅读 · 0 评论 -
[Leetcode] 154. Find Minimum in Rotated Sorted Array II (二分法进阶)
154.Find Minimum in Rotated Sorted Array II(题目链接) Hard Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7]might become [4,5,6,7,0,1,2]). Find the minimum element. The array may cont...原创 2020-08-01 11:46:14 · 242 阅读 · 0 评论 -
[Leetcode] 658. Find K Closest Elements (二分法)
658.Find K Closest Elements(题目链接) Medium Given a sorted arrayarr, two integerskandx, find thekclosest elements toxin the array. The result should also be sorted in ascending order. If there is a tie, the smaller elements are always preferred. ...原创 2020-08-01 05:28:06 · 152 阅读 · 0 评论 -
[Leetcode] 278. First Bad Version 找出左边第一个符合要求的数
278.First Bad Version (题目链接) Easy You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, .原创 2020-07-31 11:07:04 · 131 阅读 · 0 评论 -
[Leetcode] 34. Find First and Last Position of Element in Sorted Array (二分法进阶)
34.Find First and Last Position of Element in Sorted Array Medium 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(lo...原创 2020-07-31 10:51:50 · 111 阅读 · 0 评论