Coding
Find the median from a continuous data stream.
Implement a data structure that allows you to add integers from a continuous data stream and find the median of all elements so far efficiently.
Input: addNum(2), addNum(3), findMedian(), addNum(4), findMedian()
Output: 2.5 then 3.0
Explanation: After adding 2 and 3, the median is 2.5. After adding 4, the sorted stream is [2, 3, 4], making the median 3.0.
Was asked at