int Solution::findCount(const vector &A, int B) {

int low,high,mid,resFirst=-1,resSecond=-1;

low=0;

high=A.size()-1;

```
while(low<=high) //first index
{
mid=floor(low+(high-low)/2);
if(A[mid]==B)
{
resFirst=mid;
high=mid-1;
}
else if (A[mid] < B)
low=mid+1;
else
high=mid-1;
}
if(resFirst==-1)
return resFirst;
high=A.size()-1;
while(low<=high) //second index
{
mid=floor(low+(high-low)/2);
if(A[mid]==B)
{
resFirst=mid;
low=mid+1;
}
else if (A[mid] < B)
low=mid+1;
else
high=mid-1;
}
```

return resSecond-resFirst+1;

}