C++ solution using STL


#1

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

auto it=lower_bound(A.begin(),A.end(),B);
int start=it-A.begin();
auto it1=upper_bound(A.begin(),A.end(),B);
int end=it1-A.begin();

int ans=end-start;
return ans;

}