Find Minimum in Rotated Sorted Array Problem
Find Minimum in Rotated Sorted Array Problem — ExecCode Medium DSA Practice
Solve the Find Minimum in Rotated Sorted Array problem on ExecCode. Free online medium DSA practice in Binary Search. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2] if it was rotated 4 times. 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.
Examples
Input nums = [30, 35, 40, 45, 50, 5, 10, 15, 20, 25]; Output 5. Input nums = [4, 5, 6, 7, 0, 1, 2]; Output 0. Input nums = [11, 13, 15, 17]; Output 11
Constraints
n == nums.length 1 ≤ n ≤ 5000 -5000 ≤ nums[i] ≤ 5000 All the integers of nums are unique nums is sorted and rotated between 1 and n times
Practice Find Minimum in Rotated Sorted Array free on ExecCode. Browse DSA problems, topic map, and placement guides.