题解 | #旋转数组的最小数字#
旋转数组的最小数字
http://www.nowcoder.com/practice/9f3231a991af4f55b95579b44b7a01ba
int minNumberInRotateArray(vector<int> rotateArray)
{
for (size_t i = 0; i < rotateArray.size(); ++i)
{
if (rotateArray[i]>rotateArray[i + 1])
{
return rotateArray[i + 1];
break;
}
}
if (rotateArray[0] < rotateArray[1])
{
return rotateArray[0];
}
return 0;
}