摘要: 题目:Suppose a sorted array 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 ... 阅读全文
posted @ 2014-07-21 11:55 爱做饭的小莹子 阅读(3406) 评论(1) 推荐(0) 编辑
摘要: 题目: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 sorte... 阅读全文
posted @ 2014-07-21 10:44 爱做饭的小莹子 阅读(4269) 评论(1) 推荐(0) 编辑
摘要: Reference: http://blog.csdn.net/lbyxiafei/article/details/9375735题目:Implement int sqrt(int x).Compute and return the square root of x.题解: 这道题很巧妙的运用了二... 阅读全文
posted @ 2014-07-21 09:34 爱做饭的小莹子 阅读(4241) 评论(2) 推荐(1) 编辑
摘要: 题目: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... 阅读全文
posted @ 2014-07-21 08:31 爱做饭的小莹子 阅读(4074) 评论(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 @ 2014-07-21 04:20 爱做饭的小莹子 阅读(2147) 评论(0) 推荐(1) 编辑
摘要: 二分查找方法二分查找经常用来在有序的数列查找某个特定的位置。因此,应用二分查找法,这个数列必须包含以下特征:存储在数组中有序排列二分查找方法不适用于链表,因为链表方法需要遍历,应用二分查找法意义不大。一般情况下,我们默认数组是单调递增数列,且无重复元素。(有重复元素的题应该如何解决)二分查找方法递归... 阅读全文
posted @ 2014-07-21 03:53 爱做饭的小莹子 阅读(1150) 评论(0) 推荐(0) 编辑