摘要: 题目:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row is greater than the last integer of the previous row.For example,Consider the following matrix:[ [1, ... 阅读全文
posted @ 2013-05-03 04:51 tanghulu321 阅读(104) 评论(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 determine if a given target is in the array.思路:此题比较复杂,有三种情况需要判断:1. 左区间是正常的。 2. 右区间正常。 3. 左边和中间相等, 则说明左边到中间都是相同数字,此时需要判断时候和右边相等,如果不相等则搜索右 阅读全文
posted @ 2013-05-03 03:10 tanghulu321 阅读(134) 评论(0) 推荐(1) 编辑