7 / 75
Medium
Find Minimum in Rotated Sorted Array
#7arraybinary-search
Use binary search comparing mid with right boundary to determine which half contains the minimum.
Example:
Input:
[3,4,5,1,2]Output:
1 (array was originally [1,2,3,4,5] rotated 3 times)Common Mistakes:
- Comparing mid with left instead of right (fails for certain rotation points)
- Using l <= r which causes infinite loop
- Setting l = m instead of l = m + 1 when mid > right
Notes:
No duplicates in this version. Array is guaranteed to be rotated at least once. Compare with right boundary (not left) for cleaner logic.
💻
Java Solution Hidden
Enable “Show Full Solution” to view the code
Use binary search comparing mid with right boundary to determine which half contains the minimum.
Example:
Input:
[3,4,5,1,2]Output:
1 (array was originally [1,2,3,4,5] rotated 3 times)Common Mistakes:
- Comparing mid with left instead of right (fails for certain rotation points)
- Using l <= r which causes infinite loop
- Setting l = m instead of l = m + 1 when mid > right
Notes:
No duplicates in this version. Array is guaranteed to be rotated at least once. Compare with right boundary (not left) for cleaner logic.
7/75
Find Minimum in Rotated Sorted Array