C++ solution without using lower_bound and upper_bound

vector Solution::searchRange(const vector &a, int B) {
vector v;

int f=-1,s=-1;
int l=0,h=a.size()-1;
while(l<=h)
{
    int m = l + (h-l)/2;
    if(a[m]==B)
    {
        f=m;
        h=m-1;
    }
    else if(a[m]>B)
    h=m-1;
    
    else 
    l=m+1;
}
v.push_back(f);
l=f, h=a.size()-1;
    while(l<=h){
     int m = l + (h-l)/2;
     if(a[m]==B)
     {
        s = m;
         l=m+1;
     }
      else if(a[m]>B)
         h=m-1;

     else l = m+1;
    
    
}

v.push_back(s);
return v;

}

Click here to start solving coding interview questions