14. Find Minimum in Rotated Sorted Array

14. Find Minimum in Rotated Sorted Array

Medium
49.0%
1.4k
arraybinary-search
Google, Amazon, Netflix, Meta (Facebook), Apple, Microsoft, Uber, Bloomberg, Airbnb, Stripe, Adobe, Salesforce, LinkedIn, Oracle

You’re interviewing for a backend or data engineering role at a FAANG-level company. The interviewer describes a real product scenario:

A large-scale data platform stores configuration values, thresholds, or ranking scores in a sorted array for fast access. To support rolling updates and zero-downtime deployments, the platform sometimes rotates this sorted array at an unknown pivot.

As a result, the array remains sorted in ascending order but is rotated, meaning part of the array is shifted from the front to the back.

The system needs a fast and reliable way to determine the minimum value in this rotated sorted array, since that value often represents a baseline configuration or critical threshold.

This is a common practice coding problem for DSA question might ask in Google, Amazon, Netflix, Meta, Apple, Microsoft, Uber, and Bloomberg interviews.

Your Task

Given a rotated sorted array nums that was originally sorted in ascending order and contains no duplicate elements, return the minimum element in the array.

You must solve this problem using an algorithm that runs in O(log n) time.

Input Format

  • nums: a rotated sorted array of unique integers

Output Format

  • A single integer representing the minimum element in the array

Examples

Example 1:

Input: nums = [3,4,5,1,2]
Output: 1

Example 2:

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

Example 3:

Input: nums = [11,13,15,17]
Output: 11

Constraints

  • 1 <= nums.length <= 100,000
  • -10^9 <= nums[i] <= 10^9
  • All values in nums are unique
  • nums is guaranteed to be a rotated version of a sorted array

Loading editor...

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

Console Output

Click "Run Code" or "Submit" to see results

Your code will be evaluated by AI with instant feedback