One line solution using STL


#1

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

return upper_bound(A.begin(),A.end(),B) - lower_bound(A.begin(),A.end(),B);

}


#2

I mean its literally an example of binary search so this approach trivializes the problem.