Back to DSA
Find Median from Data Stream
hardDesign a data structure that accepts a continuous stream of integers and can report the median at any time. If the count of numbers is even, the median is the average of the two middle values.
Examples
Example 1:
Input:
MedianFinder(), addNum(5), addNum(3), findMedian(), addNum(8), findMedian()Output:
[null,null,null,4.0,null,5.0]Hints
1234567