Welcome to the Python screen.
The question is on your right: Streaming Median for Live Events. Read through the requirements first.
Run and submit your code as often as you need. You also have five interviewer messages this session - want to talk through your approach, or are you ready to start coding?
In a Meta live monitoring pipeline, event counts arrive one integer at a time. Implement a data structure that supports inserting a new integer from the stream and returning the median of all values seen so far at any moment.
Implement a function that processes a list of operations and returns the result for each median query.
operations: a list of operations{"op": "add", "value": x} where x is an integer{"op": "median"}median query contributes the current median.def stream_median(operations):