BackhardHeap

Realtime Middle Value Estimator Solution

Problem Statement

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.

Example 1
Input
Numbers: [12, 4, 56, 7, 23, 1]
Output
["N",null,"m",null,"e",null,"m",null]

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.

Constraints

  • The input stream can contain any positive or negative integers.
  • The system should handle a large volume of numbers efficiently.
  • Memory usage should be optimized.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free