摘要:
题目: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 ... 阅读全文
摘要:
题目: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... 阅读全文
摘要:
Reference: http://blog.csdn.net/lbyxiafei/article/details/9375735题目:Implement int sqrt(int x).Compute and return the square root of x.题解: 这道题很巧妙的运用了二... 阅读全文
摘要:
题目: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... 阅读全文
摘要:
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... 阅读全文
摘要:
二分查找方法二分查找经常用来在有序的数列查找某个特定的位置。因此,应用二分查找法,这个数列必须包含以下特征:存储在数组中有序排列二分查找方法不适用于链表,因为链表方法需要遍历,应用二分查找法意义不大。一般情况下,我们默认数组是单调递增数列,且无重复元素。(有重复元素的题应该如何解决)二分查找方法递归... 阅读全文