码迷,mamicode.com
首页 > 其他好文 > 详细

153.Find Minimum in Rotated Sorted Array

时间:2015-02-11 09:27:00      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

Suppose a sorted array is rotated at some pivot unknown to you beforehand.

(i.e., 0 1 2 4 5 6 7 mightbecome 4 5 6 7 0 1 2).

Find the minimum element.

You may assume no duplicate exists in the array.

HideTags

 Array Binary Search


 

 

int findMin(vector<int> &num) {
	int size = num.size();
	for (int i = 0; i < size - 1; i++)
		if (num[i]>num[i + 1])
			return num[i + 1];
	return num[0];//num升序排列,没有转置
}

153.Find Minimum in Rotated Sorted Array

标签:

原文地址:http://blog.csdn.net/hgqqtql/article/details/43707415

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!