Dsa
Heap
Easy
Dynamic Median Maintenance
In a theoretical city, you are responsible for maintaining a list of citizen heights as new citizens arrive continuously. Implement a program that reads from the input stream until EOF and tracks the median height after each arrival. The program should print the current median height after each new citizen's height is added. If the total number of heights is odd, the median is the middle height; if even, it is the average of the two middle heights rounded to two decimal places.
Example:
Input:
160
170
155
180
Output:
160.00
165.00
170.00
170.00
Key concepts
heapmediandynamic
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now