PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Ixl

Maintain a Stream Median

Last updated: Apr 6, 2026

Quick Overview

This question evaluates the ability to design and implement efficient online data structures and algorithms for maintaining dynamic order statistics and computing the median of a stream of integers.

  • hard
  • Ixl
  • Coding & Algorithms
  • Software Engineer

Maintain a Stream Median

Company: Ixl

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

Design a data structure for a stream of integers. It must support the following operations efficiently: - `add_num(x)`: insert an integer `x` into the stream. - `get_median()`: return the median of all numbers seen so far. The median is defined as: - the middle value when the count of numbers is odd, - the average of the two middle values when the count is even. Implement this data structure so that it can handle many insertions and median queries efficiently.

Quick Answer: This question evaluates the ability to design and implement efficient online data structures and algorithms for maintaining dynamic order statistics and computing the median of a stream of integers.

Ixl logo
Ixl
Feb 22, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
1
0
Loading...

Design a data structure for a stream of integers. It must support the following operations efficiently:

  • add_num(x) : insert an integer x into the stream.
  • get_median() : return the median of all numbers seen so far.

The median is defined as:

  • the middle value when the count of numbers is odd,
  • the average of the two middle values when the count is even.

Implement this data structure so that it can handle many insertions and median queries efficiently.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Ixl•More Software Engineer•Ixl Software Engineer•Ixl Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.