Skip to content

Latest commit

 

History

History
64 lines (46 loc) · 1.43 KB

0153-find-minimum-in-rotated-sorted-array.adoc

File metadata and controls

64 lines (46 loc) · 1.43 KB

153. Find Minimum in Rotated Sorted Array

{leetcode}/problems/find-minimum-in-rotated-sorted-array/[LeetCode - Find Minimum in Rotated Sorted Array^]

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 1:

Input: [3,4,5,1,2]
Output: 1

Example 2:

Input: [4,5,6,7,0,1,2]
Output: 0

思路分析

最省事的方式当然是遍历,但是,中等难度的题目不可能一个遍历就解决了。

针对有序数组,首先想到的就是二分查找。但是,这里的二分查找有需要做些特别处理:要判断最低点在哪个区间。

{image_attr}
{image_attr}
一刷
link:{sourcedir}/_0153_FindMinimumInRotatedSortedArray.java[role=include]
二刷
link:{sourcedir}/_0153_FindMinimumInRotatedSortedArray_2.java[role=include]