To prove safety offerQ6
Subject description:
The beginning of an array of several elements moved to the end of the array, the array we call rotation.
输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素。
例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。
NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。
Method a: direct lookup Array [i + 1]> Array [i] return Array [i]
Method two: calling the function min ()
There are binary search method: sort the array, binary search to think!
Title information is a partial ordering,
the right large direct output Array [0] than the left
if the left to the right is greater than left> +. 1 MID MID left =
right> right = MID MID shrinking range
if left ++ right- equal sides continue
Method four: python sort () function is used:
class Solution:
def minNumberInRotateArray(self, rotateArray):
# write code here
rotateArray.sort()
return rotateArray[0]