Minimum in a Rotated Sorted Array
Updated
Problem statement
Given a nonempty array nums formed by rotating a strictly increasing integer array, return its minimum element.
Rotating moves a prefix to the end while preserving the order within each part. Zero rotations are allowed. All elements are distinct.
Your solution must use O(log n) time and O(1) extra space.
Function
minimumRotatedArray(nums: int[]) → intExamples
Example 1
nums = [3,4,5,1,2]return = 1The increasing sequence [1, 2, 3, 4, 5] was rotated, and its minimum remains 1.
Example 2
nums = [1,2,3]return = 1A zero rotation is valid; the first value is the minimum.
Example 3
nums = [5]return = 5A singleton has no different minimum.
Constraints
1 <= nums.length <= 10^5-10^9 <= nums[i] <= 10^9- All values are distinct, and nums is a rotation of a strictly increasing array.
More Mygate Phone Screen questions
- Employees Earning More Than Their ManagerPHONE SCREEN · Seen Sep 2026
- Maximum Subarray SumPHONE SCREEN · Seen Sep 2026
- Reverse a Linked ListPHONE SCREEN · Seen Sep 2026
- Users Active in Both January and FebruaryPHONE SCREEN · Seen Sep 2026
- Elements Occurring More Than n/3 TimesPHONE SCREEN · Seen Jan 2025
- Frog Jump: Minimum EnergyPHONE SCREEN · Seen Jan 2025
- Left View of a Binary TreePHONE SCREEN · Seen Jan 2025
- Two SumPHONE SCREEN · Seen Aug 2024
- Minimum Subarray SumPHONE SCREEN · Seen Sep 2023
- Remove the Nth Node from the EndPHONE SCREEN · Seen Sep 2023
Similar questions at other companies
- Longest Increasing SubsequenceByteDance · PHONE SCREENByteDance interview questions
- Koko Eating BananasThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
- Find First and Last Position in a Sorted ArrayInstacart · PHONE SCREENInstacart interview questions
- Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Longest Increasing SubsequenceAngel One · PHONE SCREEN
- Aggressive CowsAmazon · PHONE SCREEN
- Search a 2D MatrixWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
- Find First and Last Position of Element in Sorted ArrayEPAM · PHONE SCREENEPAM interview questions
- Find K Closest Elements in a Sorted ArrayNavi · PHONE SCREEN
- Search in Rotated Sorted ArrayZoomInfo · PHONE SCREEN