Array rotation

Topic description
Move the first few elements of an array to the end of the array, we call it the rotation of the array.
Input a rotation of a non-decreasing sorted array, and output the smallest element of the rotated array.
For example, the array {3,4,5,1,2} is a rotation of {1,2,3,4,5}, and the minimum value of the array is 1.
NOTE: All the elements given are greater than 0, if the array size is 0, please return 0.

在这里插入代码片
public int minNumberInRotateArray(int [] array) {
    int a=array[array.length],i=array.length;
    while(array[i]>=array[i-1])
    	{a=array[i-1];
    	i--;}
    return a;
    	}
    }
Published 152 original articles · praised 16 · 30,000+ views

Guess you like

Origin blog.csdn.net/feiqipengcheng/article/details/105275288