Facebook Pixel
Find Minimum in Rotated Sorted Array
Medium

Given a sorted array that has been rotated at some unknown pivot, find the minimum element. You must write an algorithm that runs in O(log N) time.

Example:

Input: nums = [3,4,5,1,2]
Output: 1
Explanation: The minimum value in the rotated array is 1.

Input: nums = [4,5,6,7,0,1,2]
Output: 0
Explanation: The minimum value in the rotated array is 0.
Test Cases

Test Cases

Input
30 40 50 10 20
Expected Output
3
Step 1
Step 2
Step 3
Step 4
Step 1: Identify the Pattern
Find Minimum in Rotated Sorted Array
Medium

Given a sorted array that has been rotated at some unknown pivot, find the minimum element. You must write an algorithm that runs in O(log N) time.

Example:

Input: nums = [3,4,5,1,2]
Output: 1
Explanation: The minimum value in the rotated array is 1.

Input: nums = [4,5,6,7,0,1,2]
Output: 0
Explanation: The minimum value in the rotated array is 0.
Test Cases

Test Cases

Input
30 40 50 10 20
Expected Output
3
Step 1
Step 2
Step 3
Step 4
Step 1: Identify the Pattern