Simple elegant 1 line C++ solution


#1
int Solution::findCount(const vector<int> &A, int B) {
    return (upper_bound(A.begin(), A.end(), B) - lower_bound(A.begin(), A.end(), B));
}