hard
heap
priority-queue
data-stream
design
Insert the integers in nums one at a time and return the final median as a floating-point number.
Constraints
- 1 <= nums.length <= 50000
- -100000 <= nums[i] <= 100000
Follow-up
How would a MedianFinder class expose repeated addNum and findMedian calls?
Examples
Example 1
Input: nums = [1,2]
Output: 1.5
Example 2
Input: nums = [1,2,3]
Output: 2
Example 3
Input: nums = [5]
Output: 5
🔒 5 hidden
Running will execute all 8 cases, including 5 hidden ones.