class Solution:
def findMin(self, nums: List[int]) -> int:
left, right = 0, len(nums) - 1
mid = -1
while left < right:
mid = left + (right - left) // 2
if nums[mid] < nums[right]:
right = mid
elif nums[mid] < nums[left]:
left = mid
else:
while mid < right:
prev = mid
mid = mid + 1
if nums[prev] > nums[mid]:
return nums[mid]
return nums[mid]
'CS > 알고리즘' 카테고리의 다른 글
[Leetcode 334] 334. Increasing Triplet Subsequence (0) | 2023.05.02 |
---|---|
[Leetcode] 162. Find Peak Element (0) | 2023.05.02 |
[Leetcode] 74. Search a 2D Matrix (0) | 2023.05.01 |
[Leetcode] 33. Search in Rotated Sorted Array (0) | 2023.05.01 |
[Leetcode] 34. Find First and Last Position of Element in Sorted Array (0) | 2023.05.01 |