153. Find Minimum in Rotated Sorted Array
# Medium
Same as #33.
Solution 1:
find the pivot as #33
consider 2 situations: this is an ascending list or rotated list
consider edge case: 1 element
Solution 2:
find the pivot as #33.
// java efficient
class Solution {
public int findMin(int[] nums) {
int left = 0, right = nums.length - 1;
while(left < right) {
int mid = left + (right - left)/2;
if(nums[mid] > nums[right])
left = mid + 1;
else
right = mid;
}
return nums[left];
}
}
Last updated
Was this helpful?