search-for-a-range
2019-06-26 本文已影响0人
DaiMorph
class Solution {
public:
vector<int> searchRange(int A[], int n, int target) {
int start=lower_bound(A,A+n,target)-A;
int end=upper_bound(A,A+n,target)-A;
if(A[start]!=target)return vector<int>{-1,-1};
return vector<int>{start,end-1};
}
};