246. Find Median from Data Stream

Hard · Heap

Design a data structure that supports: `addNum(num)` — add a number; `findMedian()` — return the median of all added numbers. The median of an even-length dataset is the mean of the two middle values.

Examples

Example 1
Input: addNum(1); addNum(2); findMedian()→1.5; addNum(3); findMedian()→2.0
Output: [1.5, 2.0]

Constraints