Skip to content
BASA DSA

Find Minimum In Rotated Sorted Array

MediumBinary Search

A strictly increasing array was rotated at an unknown boundary, possibly zero times. Return its smallest value in logarithmic time.

Example 1

Input
nums = [7,9,1,3,5]
Output
1

Explanation

The rotation boundary is between 9 and 1, so 1 is the minimum.

Example 2

Input
nums = [1,3,8]
Output
1

Explanation

The array is already sorted, so its first value is smallest.

Example 3

Input
nums = [4]
Output
4

Explanation

A singleton's only value is its minimum.

Constraints

  • 1 <= len(nums) <= 5000
  • All values are distinct

Function contractfindMinArguments: json
Loading draft…
SolutionRuns on your device
Loading draft…