One line C++, using upper_bound


#1

int Solution::findCount(const vector &A, int B) {
int count=upper_bound(A.begin(),A.end(),B)-upper_bound(A.begin(),A.end(),B-1);
return count;
}


#2

or u can just write:
return upper_bound(A.begin(),A.end(),B)-lower_bound(A.begin(),A.end(),B);