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