class Solution {
public:
vector<int> searchRange(int A[], int n, int target) {
// Note: The Solution object is instantiated only once and is reused by each test case.
vector<int> res(2,-1);
int start=0;
int end=n-1;
while(start<end) {
int mid=(start+end)/2;
if (A[mid]>target) {
end=mid-1;
}else if (A[mid]<target) {
start=mid+1;
}
else {
end=mid;
}
}
if (A[start]==target) {
res[0]=start;
}else {
return res;
}
end=n;
while(start<end) {
int mid=(start+end)/2;
if (A[mid]>target) {
end=mid;
}else if (A[mid]<target) {
start=mid+1;
}
else {
start=mid+1;
}
}
res[1]=end-1;
return res;
}
};