Python data engineering interview problem. Difficulty: advanced. Pattern: Heaps. About 18 minutes. Part of the Pro drill bank.
Stream integers and report the running median. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
Implement class MedianFinder with addNum(num) and findMedian(). For even count, return the average of the two middle values as a float.
Input: add 1,2; findMedian; add 3; findMedian Output: 1.5 then 2 Even then odd counts.
Topics: lakebench, python, median, two heaps.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: Stream integers and report the running median.
Implement class `MedianFinder` with `addNum(num)` and `findMedian()`. For even count, return the average of the two middle values as a float. Keep the harness prints.