Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Siyu-Lei/3dcee643fb3f8ea71401ef2ad953659a to your computer and use it in GitHub Desktop.
Save Siyu-Lei/3dcee643fb3f8ea71401ef2ad953659a to your computer and use it in GitHub Desktop.
class Solution {
public int findMin(int[] nums) {
int left = 0;
int right = nums.length - 1;
while (left < right) {
int mid = left + (right - left) / 2;
if (nums[mid] <= nums[right]) {
right = mid;
} else {
left = mid + 1;
}
}
return nums[right];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment