Code Room
CodingMediumcod-g1283
Subject HeapsLevel Entry–Mid~16 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.