Title Description:moves the first element of an array to the end of the array, which we call the rotation of the array. Enter a rotation of a non-decreasing array, outputting 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 elements given are greater than 0, and if the array size is 0, return 0. Problem Solving Code:
functionMinnumberinrotatearray (rotatearray) {//Write code here if(Rotatearray.length = = 0){ return0; } //The number of the previous position of each number of non-minimum digits is less than that number for(vari = 1;i < rotatearray.length;i++){ //when a number is less than the number of the previous position, the number is the smallest array of arrays if(rotatearray[i]<rotatearray[i-1]){ returnRotatearray[i]; } }}
Sword Point Offer (6) Minimum number of rotation array