Skip to content

Commit d9bc0f1

Browse files
committed
Create Find_Minimum_in_Rotated_Sorted_Array.cc
For the reason that it assumes no duplicate exists in the array...This problem seems more easier...
1 parent 99c7347 commit d9bc0f1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
int findMin(vector<int> &num) {
4+
int L = 0, R = num.size() - 1, M;
5+
if (R < 0) return -1;
6+
while (L < R) {
7+
M = L + (R - L) / 2;
8+
if (num[M] > num[R])
9+
L = M + 1;
10+
else
11+
R = M;
12+
}
13+
return num[L];
14+
}
15+
};

0 commit comments

Comments
 (0)