Live Leaderboard Cutoff
easyA climbing gym runs a season-long competition: the top k scores qualify for finals, and after every new score comes in, the display board shows the current qualifying cutoff — the k-th largest score so far.
Operations format. Your function receives three arguments: ops, a list of operations each of the form ["add", score]; the integer k; and initial, the list of scores already on the board (may be shorter than k). Process the operations in order and return a list with one entry per operation: the k-th largest score after that add. Every add is guaranteed to leave at least k scores total.
Example 1
in ops = [["add", 3], ["add", 5], ["add", 10], ["add", 9], ["add", 4]], k = 3, initial = [4, 5, 8, 2]
out [4, 5, 5, 8, 8]
After adding 3 the scores are [4,5,8,2,3]; the 3rd largest is 4. Each later add may raise the cutoff.
Example 2
in ops = [["add", -3], ["add", 0]], k = 1, initial = []
out [-3, 0]
With k = 1 the cutoff is simply the maximum so far.
Constraints
- · 1 <= k <= 100
- · 0 <= len(initial) <= 1000
- · 1 <= len(ops) <= 1000
- · -10^4 <= score <= 10^4
- · every query has at least k scores available
solution.py● loading python…
test results
Hit ▶ Run to test your code against the visible cases.