Created
May 24, 2018 03:55
-
-
Save Siyu-Lei/3dcee643fb3f8ea71401ef2ad953659a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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