-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Time: 4 ms (70.67%), Space: 10.2 MB (71.72%) - LeetHub
- Loading branch information
1 parent
a80ba75
commit 338a59f
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
153-find-minimum-in-rotated-sorted-array/153-find-minimum-in-rotated-sorted-array.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Solution { | ||
public: | ||
int findMin(vector<int>& nums) { | ||
int n=nums.size(); | ||
|
||
int lo=0, hi=n-1; | ||
|
||
while(lo<hi){ | ||
int mid=lo+(hi-lo)/2; | ||
|
||
if(nums[mid]>nums[hi]) | ||
lo=mid+1; | ||
|
||
else hi=mid; | ||
} | ||
|
||
return nums[hi]; | ||
} | ||
}; |