Drop the Lowest Scores
Remove k values from scores, one at a time: each time, remove the smallest value still present, and when that smallest value occurs more than once, remove its earliest occurrence. Stop early if the list becomes empty.
Return the remaining values in their original order. With k = 0 the list is returned unchanged, and when k is at least len(scores) the result is an empty list.
Example 1
scores [5,3,8,3,1]
k 2
returns [5,8,3]
The 1 goes first. The next smallest is 3, which occurs twice, so the earlier 3 (at index 1) goes and the later one stays.
Example 2
scores [4,4,4]
k 1
returns [4,4]
All three values are equal, so the first one is removed.
Constraints
0 <= len(scores) <= 100-1000 <= scores[i] <= 10000 <= k <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.