摘要: 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.class Solution {public: bool help(int *a,int from,int to,int x) { if (from > to) { r... 阅读全文
posted @ 2013-09-15 15:35 一只会思考的猪 阅读(166) 评论(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. int rotateSearch(int A[], in... 阅读全文
posted @ 2013-09-15 15:15 一只会思考的猪 阅读(180) 评论(0) 推荐(0) 编辑