LeetCode 153. Find Minimum in Rotated Sorted Array [Medium]

LeetCode 153. Find Minimum in Rotated Sorted Array。

题目来源:https://leetcode.com/problems/find-minimum-in-rotated-sorted-array

题目难度:Medium

解答1[Java]:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Solution {
public int findMin(int[] nums) {
if (nums.length == 0) {
return 0;
}

int min = nums[0];

for (int i = 1; i < nums.length; ++i) {
if (nums[i] < min) {
return nums[i];
}
}

return min;
}
}