find-median-from-data-stream.sh — zsh
Find Median from Data Stream
hardheappriority-queuedata-streamdesign
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?
ExamplesExample 1Input: nums = [1,2]
Output: 1.5
Example 2Input: nums = [1,2,3]
Output: 2
Example 3Input: nums = [5]
Output: 5
🔒 5 hidden
Running will execute all 8 cases, including 5 hidden ones.