C++ std::equal_range solution

vector<int> Solution::searchRange(const vector<int> &A, int B) {
    auto r = equal_range(A.begin(), A.end(), B);
    if (r.first!=A.end() && *r.first!=B)
        return {-1, -1};
    return { r.first-A.begin(), r.second-A.begin()-1 };
}
Click here to start solving coding interview questions