As reported: Intuit SWE intern (on-campus, 2026), proctored OA on Glider, question 2 of 4: the median of a data stream, solved with heaps.
Implement a MedianFinder class:
MedianFinder()creates an empty structure.addNum(num)adds an integer from the stream.findMedian()returns the median of all numbers added so far — the middle value, or the mean of the two middle values when the count is even.
This is LeetCode 295 — Find Median from Data Stream.
Example
MedianFinder, addNum(1), addNum(2), findMedian() -> 1.5, addNum(3), findMedian() -> 2.0
Constraints: -10^5 ≤ num ≤ 10^5; findMedian is called only after at least one addNum; up to 5·10^4 calls in total.
Code runner format: one JSON value per line (LeetCode's test-case format): the list of operation names, then the list of their arguments. The harness prints the results as a JSON list, null for the constructor and addNum, and medians with 5 decimals.