Approach hintTry it first, then revealHide
Visit students in decreasing order of skill and skip those already taken. A doubly linked list over the remaining positions lets you remove the k nearest neighbours on each side in O(k).
Visit students in decreasing order of skill and skip those already taken. A doubly linked list over the remaining positions lets you remove the k nearest neighbours on each side in O(k).