Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int findMin(vector<int>& nums) {
- int n = nums.size();
- int l = 0, h = n-1;
- while(l<h){
- int m = l + (h-l)/2;
- if(nums[0]-nums[m]>0){
- h = m;
- }
- else{
- l = m+1;
- }
- }
- if(nums[0]-nums[l]<0) return nums[0]; //If the array is completely sorted
- return nums[l];
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement