18 · Binary Search

#153 Find Minimum in Rotated Sorted Array

Mediumsolve on LeetCode ↗

frequently reported atMicrosoftAmazonMetaGoogleBloomberg

the problem

In plain words

A sorted array of unique values was rotated 1 to n times. Return its minimum element in O(log n).

in nums = [3,4,5,1,2]

out 1

in nums = [4,5,6,7,0,1,2]

out 0

in nums = [11,13,15,17]

out 11

Rotated n times — back to sorted.

  • 1 ≤ n ≤ 5000
  • -5000 ≤ nums[i] ≤ 5000
  • All unique

your turn

Try it before you peek

Read the examples, say the brute force out loud, then write code: here or on LeetCode ↗. Stuck for 20 minutes? Open one hint at a time.

Solve it in the browser

LeetCode-style: complete the class. Compiled by the real javac (Java 17) and judged right here — nothing is sent anywhere.

    Solutions are hidden so you can try first. Even 20 minutes of real effort makes the answer stick far better than reading it.

    Marking the problem solved, or opening every hint, also shows it.

    practise next

    Similar problems

    1. #33
      Search in Rotated Sorted Array
      Mediumin Binary Search
    2. #162
      Find Peak Element
      Mediumin Binary Search