
二分查找题型
POFEI_IS_SHIT
不是我针对谁,在座的各位都是垃圾
展开
-
34. Search for a Range
Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the target is原创 2017-06-16 10:11:39 · 253 阅读 · 0 评论 -
35. Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Here原创 2017-06-16 10:23:11 · 152 阅读 · 0 评论 -
50. Pow(x, n)
Implement pow(x, n).Subscribe to see which companies asked this question.题意:考虑n=-2147483648的情况class Solution {public: double myPow(double x, int n) { if(n < 0) x = 1 / x;原创 2017-06-16 20:09:56 · 233 阅读 · 0 评论 -
74. Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right. The first integer of each row is原创 2017-06-19 11:11:47 · 188 阅读 · 0 评论 -
153. Find Minimum in Rotated Sorted Array
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 duplicate exist原创 2017-06-20 09:10:04 · 180 阅读 · 0 评论 -
69. Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x.题意:求一个数的平方根。二分查找class Solution {public: int mySqrt(int x) { int l, r; long long mid; l = 0, r = x;原创 2017-06-19 10:16:04 · 215 阅读 · 0 评论 -
33. Search in Rotated Sorted Array
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).You are given a target value to search. If found in the ar原创 2017-06-15 21:01:21 · 193 阅读 · 0 评论 -
410. Split Array Largest Sum
Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m suba转载 2017-10-08 11:26:23 · 967 阅读 · 0 评论