Find Minimum in Rotated Sorted Array
Problem: Find Minimum in Rotated Sorted Array
The general idea to solve this problem is to find the pivot point where the next number is smaller than current number. The only special condition we need to consider is that the minimum number is at head or tail of the list.
Code in Python:
class Solution(object):
def findMin(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if len(nums) == 1:
return nums[0]
for i in xrange(len(nums)-1):
if nums[i] > nums[i+1]:
return nums[i+1]
return min(nums[i], nums[0])