Simplest C++ solution using STL

vector<int> Solution::solve(vector<int> &A, int B) {
    sort(A.begin(), A.end(), greater<int>());
    A.erase(A.begin() + B, A.end());
    return A;
}

more like dumbest solution ever, try solving it with heap instead of just sorting the array

Click here to start solving coding interview questions