登录
  • #刷题
  • #careercup

CC150 Chapter 10 Sorting and Searching 10.3 题干疑问

yyz20002008
1019
2
CC150 第五版

10.3 Given a sorted array of n integers that has been rotated an unknown number of times, write code to find an element in the array. You may assume that the array was originally sorted in increasing order.

这个题都是说和leetcode的search in rotated sorted array 一样的,一般都是讲rotated了一次

像这样{15,16,19,20,25,1,3,4,5,7,10,14}。

二分法每次就可以用中点和两边的值来确定哪边是递增哪边是rotated了从而缩小范围。

但这题题干说是rotated an unknown number of times,这是什么意思?rotated 很多次的意思?

不就变成类似这样

{1,3,4,5,15,16,19,20,25,7,10,14}

挺让人confused,不仅没规律可循了,而且极端情况不就无序了,这题不就有问题了嘛?

我可能逗比了,大家来解下惑,谢谢了
2条回复
热度排序

发表回复