3 lines code, O(log n) complexity


#1
vector<int> Solution::searchRange(const vector<int> &A, int B) 
{
    if(binary_search(A.begin(), A.end(), B) == false) return {-1, -1};
    
    int x = lower_bound(A.begin(), A.end(), B) - A.begin();
    int y = upper_bound(A.begin(), A.end(), B) - A.begin();
    
    return {x, y-1};
}