Minimum of a Rotated Sorted Array
Find the smallest value of a sorted array that has been rotated.
The problem
Implement Solution.findMin(nums). nums holds between 1 and 5,000 distinct integers. It was sorted in increasing order and then rotated zero or more times, so [1, 2, 3, 4, 5] might become [3, 4, 5, 1, 2] or stay as it is. Return the smallest value in nums. Your solution must run in O(log n) time.
Starter code
class Solution:
def findMin(self, nums):
passPublic examples
nums = [3, 4, 5, 1, 2]gives1nums = [-4]gives-4nums = [2, 3, 4, 5, 1]gives1
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
