Skip to content

Commit

Permalink
Create Find_Minimum_in_Rotated_Sorted_Array
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-rohit0 committed Oct 28, 2022
1 parent 8dfe2fe commit 8fb6e70
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Find_Minimum_in_Rotated_Sorted_Array
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Author : Rohit Sharma
// Language : CPP

class Solution {
public:
int findMin(vector<int>& nums) {
int s= 0;
int n = nums.size();
int e = n-1;
int mid = s+(e-s)/2;
if(nums[s]<nums[e]){
return nums[s];
}

while(s<e){
if(nums[mid] >= nums[0]){
s = mid+1;
}

else{
e=mid;
}
mid = s+(e-s)/2;
}
return nums[s];
}
};

0 comments on commit 8fb6e70

Please sign in to comment.