Design a system that maintains a sequence of numbers and calculates the median after each new number is added, ensuring the median is always up-to-date. The system should handle a large volume of numbers efficiently.
Explanation: The median is calculated as the middle value in the sorted sequence. When the sequence length is even, the median is the average of the two middle values.
Running median using two heaps
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak