-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Description
Bug Report for https://neetcode.io/problems/find-minimum-in-rotated-sorted-array
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
My input :
nums=[2, 2, 2, 0, 1, 2]
Expected output should be 0 but I'm getting 2...
This was your solution which is giving correct output as 0 but expected output is shown as 2
class Solution:
def findMin(self, nums: List[int]) -> int:
res = nums[0]
l, r = 0, len(nums) - 1
while l <= r:
if nums[l] < nums[r]:
res = min(res, nums[l])
break
m = (l + r) // 2
res = min(res, nums[m])
if nums[m] >= nums[l]:
l = m + 1
else:
r = m - 1
return res
Metadata
Metadata
Assignees
Labels
No labels