Loading...

The Median Keeper

A hard Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
hard
Seniority
senior, staff

Problem

A real-time analytics system needs to maintain a running median as values stream in. Given a list of integers representing a data stream in order, return a list of the median value after each new element is added. Use two heaps to maintain an efficient O(log n) insertion.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.