随笔分类 -  Binary Search

二分查找
摘要: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]). Y 阅读全文
posted @ 2018-09-13 23:43 丶Blank 阅读(146) 评论(0) 推荐(0)
摘要:Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to... 阅读全文
posted @ 2015-09-17 21:09 丶Blank 阅读(171) 评论(0) 推荐(0)
摘要: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 c... 阅读全文
posted @ 2015-09-11 16:21 丶Blank 阅读(168) 评论(0) 推荐(0)
摘要:Implementint sqrt(int x).Compute and return the square root ofx.题目大意:实现求一个int的根。解题思路:二分。public class Solution { public int mySqrt(int x) { i... 阅读全文
posted @ 2015-06-25 13:36 丶Blank 阅读(169) 评论(0) 推荐(0)
摘要: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 or... 阅读全文
posted @ 2015-06-25 11:19 丶Blank 阅读(132) 评论(0) 推荐(0)
摘要:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord... 阅读全文
posted @ 2015-06-08 01:08 丶Blank 阅读(154) 评论(0) 推荐(0)
摘要:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.题目大意:不用乘除取模运算计算两个数的除。解题思路:只能用位运算了,当被除数大于... 阅读全文
posted @ 2015-05-19 19:33 丶Blank 阅读(150) 评论(0) 推荐(0)
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.You m... 阅读全文
posted @ 2015-04-22 12:08 丶Blank 阅读(186) 评论(0) 推荐(0)