Question bank › Heap
Dsa Heap Easy

Median Maintenance

You are tasked with maintaining a rolling median for a series of integers coming in. As each number is added, you should return the current median. Write a program that reads integers from input until EOF. For each integer input, output the current median so far. Input Format: - A sequence of integers, one per line. Output Format: - The median after each integer input, with one median per line. Example: Input: 1 5 2 4 3 Output: 1 3.0 2.0 3.0 3.0

Key concepts

heapmedianpriority queue

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.