Skip to content

Commit

Permalink
cpp implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Azureki committed Apr 25, 2019
1 parent a5f5a5b commit cd48a93
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 153. Find Minimum in Rotated Sorted Array/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* You may assume no duplicate exists in the array. */
#include <vector>
using namespace std;
class Solution {
public:
int findMin(vector<int> &nums) {
auto left = nums.begin(), right = nums.end() - 1;
auto mid = left;
while (*left > *right) {
mid = (right - left) / 2 + left;
if (*mid < *left) {
right = mid;
} else {
left = mid + 1;
}
}
return *left;
}
};

0 comments on commit cd48a93

Please sign in to comment.