Minimum in a Rotated Sorted Array
Updated
Problem statement
An array of different integers was sorted in increasing order and then rotated: some values were taken off the end and put, in the same order, at the front. For example, [10,20,30,40,50] rotated by 2 becomes [40,50,10,20,30]. The array may also not be rotated at all.
You are given the rotated array nums. Return its smallest value.
Function
findMin(nums: int[]) → intExamples
Example 1
nums = [30,40,50,10,20]return = 10The array was [10,20,30,40,50] before it was rotated. The values climb from 30 to 50, then drop to 10. The value right after the drop is the smallest one, 10.
Example 2
nums = [-5,-2,3,8]return = -5This array was not rotated at all, so it is still in increasing order and the smallest value is the first one, -5.
Example 3
nums = [6,9,12,-4]return = -4The smallest value, -4, ended up in the last position.
Constraints
1 <= nums.length <= 10^4-10^9 <= nums[i] <= 10^9- All values in
numsare different, andnumsis an increasing array rotated some number of times (possibly zero).
More Expedia Onsite Interview questions
- Scramble StringONSITE INTERVIEW · Seen Sep 2026
- Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
- Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
- Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
- Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
- Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
- Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
- Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
- Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024
- Maximum Supplier ProfitONSITE INTERVIEW · Seen Aug 2024
Similar questions at other companies
- 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 in a Rotated Sorted ArrayAmazon · PHONE SCREEN · ONSITE INTERVIEW
- 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
- Detect a Silent SensorConfluent · ONSITE INTERVIEWConfluent interview questions
Interview reports that mention this question
Expedia interview experiences
- Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
- Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
- Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
- Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
- Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)