Quick Overview

Design a MedianFinder that supports arbitrary integer insertions and constant-time median queries. Use balanced max and min heaps for the lower and upper halves, with O(log n) insertion and correct averaging for even counts.

Maintain the Median of an Integer Stream

Company: StackAdapt

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

Overview: Design a MedianFinder that supports arbitrary integer insertions and constant-time median queries. Use balanced max and min heaps for the lower and upper halves, with O(log n) insertion and correct averaging for even counts.

Loading…