Kth largest element stream
Your task
Maintain the k-th largest element in a stream. Process ops of the form ['add', x]; after each add, if at least k elements have been seen, report the current k-th largest value, otherwise report -1. Return the list of reported values, one per 'add'. k >= 1.
Examples
kth_largest_stream(k: int, ops: list[list]) -> list[int]Example 1
Input
kth_largest_stream(3, [["add", 4], ["add", 5], ["add", 8], ["add", 2], ["add", 3], ["add", 5], ["add", 10], ["add", 9], ["add", 4]])Output
[-1, -1, 4, 4, 4, 5, 5, 8, 8]