LeetCode 153. Find Minimum in Rotated Sorted Array

Description
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
Find the minimum element.
You may assume no duplicate exists in the array.
Example
问题分析
本题为典型的
二分搜索问题;首先根据
翻转前后(Rotate/No Rotated)的不同状态,确定二分搜索的子粒度;

之后,本题所求目标为
数组中的最小值,因此每种状态下均始终向最小值所在的方向,逐步缩小求解区间即可。
Submission
版权声明: 本文为 InfoQ 作者【隔壁小王】的原创文章。
原文链接:【http://xie.infoq.cn/article/c10d47156b42439bb33f238f6】。文章转载请联系作者。











评论