---
# System prepended metadata

title: 153-Find Minimum in Rotated Sorted Array
tags: [Medium]

---

# 153-Find Minimum in Rotated Sorted Array
###### tags: `Medium`
## Question
https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/
## Key
只要有旋轉超過一半，就代表nums[0]會小於nums[mid]，就代表最小值會在mid右邊
## Reference
## Solution
```cpp=
class Solution {
public:
    int findMin(vector<int>& nums) {
        if(nums[0] < nums[nums.size() - 1]) return nums[0];
        int pivot = nums[0];
        return findHelper(nums, 0, nums.size() - 1, pivot);
    }
    int findHelper(vector<int>& nums, int left, int right, int pivot) {
        if(left >= right) return nums[left];
        int mid = left + (right - left) / 2;
        if(nums[mid] >= pivot)
            return findHelper(nums, mid + 1, right, pivot);
        else
            return findHelper(nums, left, mid, pivot);
    }
};
```