---
description: LeetCode 154
---

# Find Minimum in Rotated Sorted Array

```python
class Solution:
    def findMin(self, nums):
        """
        此題為元素可以重複
        :type nums: List[int]
        :rtype: int
        """
        i = 0
        j = len(nums) - 1
        
        while i < j:                
            mid = int((j+i)/2)            
            if nums[mid] > nums[j]:
                i = mid + 1
            else:
            """
            [3, 3, 1, 3]
            考慮這個例子
            當 mid = 1 j = 3 的時候,
            中間可能會夾雜小於3的數
            所以不能直接 mid = j
            """
                if nums[j] != nums[mid]:
                    j = mid
                else:
                    j = j - 1
        return nums[i]
```
