Design a structure that ingests numbers one at a time and can report the median of everything seen so far at any moment.
Running statistics over a live stream — you have done this on instrument output. The elegant answer is two heaps.
Input: add(1); add(2); median(); add(3); median()
Output: 1.5, then 2
// hit Run to execute the sample tests
// Interactive editor preview. Live code execution arrives with your early-access cohort.