# 剑指 Offer 11. 旋转数组的最小数字(Sword finger offer 11 Minimum number of rotation array)-其他

## 剑指 Offer 11. 旋转数组的最小数字(Sword finger offer 11 Minimum number of rotation array)

``````import java.util.Map;

class Solution {
public int minArray(int[] numbers) {
int left = 0, right = numbers.length - 1;
while (left < right) {
int mid = left + (right - left) / 2;
if (numbers[mid] < numbers[right]) {
right = mid;
} else if (numbers[mid] > numbers[right]) {
left = mid + 1;
} else {
right--;
}
}
return numbers[left];
}
}
``````
————————

Moving the first elements of an array to the end of the array is called array rotation.

Give you an array of ， numbers that may have ， repeated ， element values. It was originally an array arranged in ascending order and rotated once according to the above situation. Please return the smallest element of the rotation array. For example, if the array [3,4,5,1,2] is a rotation of [1,2,3,4,5], the minimum value of the array is 1.

Source: leetcode
The copyright belongs to Lingkou network. For commercial reprint, please contact the official authorization, and for non-commercial reprint, please indicate the source.

``````import java.util.Map;

class Solution {
public int minArray(int[] numbers) {
int left = 0, right = numbers.length - 1;
while (left < right) {
int mid = left + (right - left) / 2;
if (numbers[mid] < numbers[right]) {
right = mid;
} else if (numbers[mid] > numbers[right]) {
left = mid + 1;
} else {
right--;
}
}
return numbers[left];
}
}
``````