Practice / Software

Running median of a stream

Hard · Coding (typed)

Numbers arrive one at a time. Design a class with add(num) and median(), where median() returns the median of everything added so far. Aim for O(log n) add and O(1) median.

Create a free account to answer it and get scored on what a strong answer covers.