---
# System prepended metadata

title: 153. Find Minimum in Rotated Sorted Array
tags: [leetcode]

---

# 153. Find Minimum in Rotated Sorted Array
#### Difficulty: Medium
link: https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/

### 1. Binary Search  
#### $O(log\ n)$ runtime, $O(1)$ space

題目限制$O(log\ n)$複雜度，所以想到用binary search，套用binary search模板如下。

條件`nums[mid] <= nums[-1]`製造單調性[False, False, False, True, True]，binary search找到滿足條件最小的index。

##### python
```python=
class Solution:
    def findMin(self, nums: List[int]) -> int:        
        left, right = 0, len(nums) - 1
        
        while left < right:
            mid = left + (right - left) // 2
            if nums[mid] <= nums[-1]:
                right = mid
            else:
                left = mid + 1
        
        return nums[left]
```

###### tags: `leetcode`