int findMin(vector<int> &A) {
int l = 0, r = A.size()-1;
while(l < r) {
if (A[l] < A[r])
break;
int m = l + (r-l)/2;
if (A[m] < A[r])
r = m;
else if (A[m] > A[r])
l = m+1;
else {
r--;
l++;
}
}
return A[l];
}
Online Judge Solutions
- Google (1)
- LeetCode Solutions (32)
- LintCode Solutions (68)
- Marked (38)
- Misc. (8)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment