> For the complete documentation index, see [llms.txt](https://chiragjain.gitbook.io/neetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chiragjain.gitbook.io/neetcode/153-find-minimum-in-rotated-sorted-array/code.md).

# CODE

```python
class Solution:
    def findMin(self, nums: List[int]) -> int:
        res = nums[0]
        l, r = 0, len(nums) - 1
        
        while l <= r:
            # This will only happen if the array is sorted to begin
            # with OR we are in the right part
            if nums[l] < nums[r]:
                res = min(res, nums[l])
                break
            m = (l + r) // 2
            # This mid could be the pivot / minimum element
            res = min(res, nums[m])
            # All the elements to the left are now useless
            if nums[m] >= nums[l]:
                l = m + 1
            # All the elements to the right are now useless
            else:
                r = m - 1
        return res
        
```
