摘要: 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.思路:解题思路和Search in Rotated Sorted Array差不多,但是出现了另一种情况有重复元素出现,头尾指针各向中间移一步。然后在进行判断。class Solution 阅读全文
posted @ 2014-04-01 09:42 Awy 阅读(128) 评论(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).You are given a target value to search. If found in the array return its index, otherwise return -1.You may assume no duplicate exists in the array.解题思路:这题旋转排序数组,查找目标值并返回其位置。Rotate 阅读全文
posted @ 2014-04-01 08:40 Awy 阅读(127) 评论(0) 推荐(0) 编辑