题解 | 旋转排列之找出最矮的牛
旋转排列之找出最矮的牛
https://www.nowcoder.com/practice/ea91217beb83444aa324b86bfab4a952
import java.util.*;
public class Solution {
public int findMin (int[] heights) {
final int n = heights.length;
if (heights[0] >= heights[n - 1]) {
return heights[0];
}
int l = 0, r = n - 1;
// [0, l) decrease [r, n)
while (l < r) {
final int m = l + ((r - l) >> 1);
if (heights[m] <= heights[0]) {
l = m + 1;
} else if (heights[m] >= heights[n - 1]) {
r = m;
}
}
return heights[l - 1];
}
}


