The Blind 75 Leetcode Series: Find Minimum in Rotated Sorted Array
Today, we are working on 153. Find Minimum in Rotated Sorted Array
Suppose an array of length
n
sorted in ascending order is rotated between1
andn
times. For example, the arraynums = [0,1,2,4,5,6,7]
might become:
[4,5,6,7,0,1,2]
if it was rotated4
times.
[0,1,2,4,5,6,7]
if it was rotated7
times.Notice that rotating an array
[a[0], a[1], a[2], ..., a[n-1]]
1 time results in the array[a[n-1], a[0], a[1], a[2], ..., a[n-2]]
.Given the sorted rotated array
nums
of unique elements, return the minimum element of this array.You must write an algorithm that runs in
O(log n) time.
We have a list of unique numbers, rotated at least once and at most n
times, where n
is the length of the list. The question is not asking us to find the number of times it’s being rotated but simply finding the minimum.
The question itself is actually already pretty self explanatory. Something that might help us include
- Do we expect an empty list?