Code RoomRunning median of stream
MediumPrep Room Coding #468

Running median of stream

CodingAlgorithms & data structuresEntry–Mid~16 min

A smart energy meter posts one integer power reading at a time. After each reading arrives, the dashboard wants the median of all readings received so far. To keep everything in integers, report each median doubled: for an odd count report 2 times the middle value; for an even count report the sum of the two middle values. Return the list of doubled medians, one per reading, in arrival order. Example: readings = [5, 2, 8] gives [10, 7, 10].

Implement
running_median_doubled(readings: list[int]) → list[int]
Examples
in[[5,2,8]]out[10,7,10]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 16 min
InputExpectedGot
[[5,2,8]][10,7,10]not run yetsample