Find Minimum in Rotated Sorted Array

Medium Solved

Description

Suppose an array of length n sorted in ascending order is rotated between 1 and n times.

Given the rotated sorted array nums, return the minimum element of this array.

You must write an algorithm that runs in O(log n) time.

Input format:

  • Line 1: Rotated sorted array as JSON

Examples

Input:
[3,4,5,1,2]

Output:
1
Input:
[4,5,6,7,0,1,2]

Output:
0
Input:
[11,13,15,17]

Output:
11

Note:

Print only the minimum value so it can be compared with expected output.

No submissions yet.

Discuss binary search logic, pivot detection, and edge cases with no rotation.

Test Cases