Skip to content

Bug Report for find-minimum-in-rotated-sorted-array [test cases are not exhaustive] #4409

@omgyukiel

Description

@omgyukiel

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.

test case:
[8, 9, 0, 1, 2, 3, 4, 5, 6]

my code will fail this test case, but pass the submit test cases:

    def findMin(self, nums: List[int]) -> int:
        l = 0
        r = len(nums) - 1
        minNum = float('inf')
        while l <= r:
            mid = (l + r) // 2
            minNum = min(minNum, nums[mid])
            if mid - 1 >= 0:
                minNum = min(minNum, nums[mid - 1])
            if nums[r] < nums[l]:
                l = mid + 1
            else:
                r = mid - 1

        return minNum```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions