Minimum in a Rotated Sorted Array
Updated
Problem statement
The array nums contains distinct integers. It was sorted in strictly increasing order and then rotated; a full-length rotation may leave it unchanged.
Return the minimum value in the array. Your final algorithm must use O(log n) time, where n = nums.length.
Function
findMin(nums: int[]) → intExamples
Example 1
nums = [3,4,5,1,2]return = 1The increasing lower segment begins at 1.
Example 2
nums = [4,5,6,7,0,1,2]return = 0A rotation places 0 between 7 and 1.
Example 3
nums = [11,13,15,17]return = 11A full-length rotation leaves the increasing array unchanged.
Constraints
1 <= nums.length <= 5000.-5000 <= nums[i] <= 5000.- All values are distinct, and
numsis a rotation of a strictly increasing array.
More NVIDIA Onsite Interview questions
- Check Endianness Of A Byte ArrayONSITE INTERVIEW · Seen Sep 2026
- Implement MallocONSITE INTERVIEW · Seen Sep 2026
- Implement PrintfONSITE INTERVIEW · Seen Sep 2026
- Merge Two Arrays Into Sorted OrderONSITE INTERVIEW · Seen Sep 2026
- Middle Node Of A Linked ListONSITE INTERVIEW · Seen Sep 2026
- Ping Reply TrackingONSITE INTERVIEW · Seen Sep 2026
- Reverse A StringONSITE INTERVIEW · Seen Sep 2026
- Maximum Fish in a GridONSITE INTERVIEW · Seen Sep 2024
- First Register Overflow TickONSITE INTERVIEW · Seen May 2024
- Two-Egg DroppingONSITE INTERVIEW · Seen May 2024
Similar questions at other companies
- Search in a Rotated Sorted ArrayAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Search a Row- and Column-Sorted MatrixByteDance · ONSITE INTERVIEWByteDance interview questions
- First and Last Target Position in a Mountain ArrayGoogle · ONSITE INTERVIEWGoogle interview questions
- 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Smallest Batch Size Within a Step LimitMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Peak of an Increasing-Then-Decreasing ArraySnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
- Online Meeting Scheduler with Fixed RoomsUber · ONSITE INTERVIEWUber interview questions
- Search a 2D MatrixWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
- Search in Rotated Sorted ArrayKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
- Find First and Last Position in Sorted ArrayPaytm · ONSITE INTERVIEWPaytm interview questions