Leetcode 154 Solution
This article provides solution to leetcode question 154 (find-minimum-in-rotated-sorted-array-ii)
Access this page by simply typing in "lcs 154" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii
Solution
class Solution:
def findMin(self, nums: List[int]) -> int:
l = 0
r = len(nums) - 1
while nums[l] == nums[r] and l < r:
l += 1
while l < r:
m = (l + r) // 2
if nums[m] <= nums[-1]:
r = m
else:
l = m + 1
return nums[l]