# Find the median from a data stream — hard coding question

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/6008/find-median-from-data-stream
Source observed: 2026-11-05T00:06:15.812Z
Last checked: 2026-11-05T00:06:15.812+00:00
Indexed: 2026-11-06T19:29:25.888+00:00

---

# Find the median from a data stream

**Difficulty:** Hard  
**Category:** [Data Structures & Algorithms](https://www.aced.io/questions?type=algorithms) · [Coding](https://www.aced.io/questions?type=coding)  
**Associated role:** [Software Engineer](https://www.aced.io/questions?role=swe)  
**Associated companies:** [Microsoft](https://www.aced.io/questions?company=microsoft), [Bloomberg](https://www.aced.io/questions?company=bloomberg), [Amazon](https://www.aced.io/questions?company=amazon), [Meta](https://www.aced.io/questions?company=meta-facebook)

We use this question to assess how you design a data structure for an incrementally arriving stream of numbers.

## Problem

Design a data structure that supports these operations:

- `add_num(int num)`: Adds a number to the current data stream.
- `find_median()`: Returns the median of all numbers added so far.

The median is the middle value in a sorted list. If the list has an even number of elements, the median is the average of the two middle elements.

## Example

```text
Input: ["MedianFinder", "add_num", "add_num", "add_num", "find_median", "add_num", "find_median"]
       [[], [5], [15], [1], [], [3], []]
Output: [None, None, None, None, 5.0, None, 4.0]
```

The sequence adds `5`, `15`, and `1`; the first median is `5.0`. After adding `3`, the median is `4.0`.

The page includes an editor with **Editor**, **Share**, **Output**, **Test Results**, and **Console** panels. [Sign up to run code](https://www.aced.io/signup?src=lesson). Detailed company statistics require [Upgrade](https://www.aced.io/upgrade?src=questions).

## Interview experiences

Three interview experiences are shared for this question:

- **[Microsoft · 8 months ago](https://www.aced.io/experiences/microsoft-software-engineer-interview-5c40e3)** — Software Engineer, Entry Level / L3. The candidate described a screen followed by three loop rounds, all four interviews back to back in one day. Coding questions were standard, but each included a follow-up that invalidated the candidate’s first answer. For the median problem, the interviewer bounded the input range and pressed on edge cases in the editor. The candidate found the recruiter’s format and logistics communication clear and the rounds punctual, but found the schedule draining, with behavioral questions mixed into coding rounds and consequent context switching.
- **[Amazon · 2 years ago](https://www.aced.io/experiences/amazon-software-engineer-intern-interview-8b7d93)** — Software Engineer, Intern. The candidate described the process as smooth overall, but said it took more than a month after the final interview to hear about the offer, potentially while headcount was still being determined. The questions were described as easy-to-medium LeetCode questions.
- **[Meta · 3 years ago](https://www.aced.io/experiences/meta-facebook-software-engineer-interview-2cb8a8)** — Software Engineer, Entry Level / L3. The candidate said the process matched expectations, scheduling and rescheduling were quick, and all questions had been encountered before through LeetCode-tagged material.

## Related question

- [Find the median of two sorted arrays.](https://www.aced.io/questions/4322/median-of-two-sorted-arrays)

## Related courses

### [Software Engineering Interview Prep](https://www.aced.io/courses/software-engineering)

![Software Engineering Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/4VkuYewBHUFIVUS5oJDW5h/02e833439b1289f25f38f13f81cbdca3/adobe_stock_optimized.jpeg?w=800&h=800&fm=webp&q=75)

We teach strategies for landing software engineering roles at Google, Amazon, Microsoft, Meta, Apple, and other companies through mock interviews, frameworks, and advice from senior candidates. Topics include data structures, algorithms, system design, people management, behavioral interviews, and more.

### [System Design Interviews](https://www.aced.io/courses/system-design-interviews)

![System Design Interviews](https://images.ctfassets.net/x78yjrjc11pq/78x7miFZFjBCrM5GqftrMJ/2f6d26e632c4e7265c49f6a180227edb/system_design_track_compressed_26ac98a46e__281_29_5be2280f31.jpeg?w=800&h=800&fm=webp&q=75)

We teach approaches to current system design questions across product, infrastructure, and AI domains, with in-depth video examples, written breakdowns, reference patterns, and mock-interview videos featuring senior engineers and managers.

## Related Aced resources

We provide interview preparation across product management, forward-deployed engineering, engineering management, software engineering, system design, data science, machine learning, data engineering, AI engineering, investment banking, generative AI, security engineering, TPM, solutions architecture, UX/product design, and BizOps & Strategy. We also provide interview experiences, practice, coaching, resume review, salary negotiation, job referrals, and additional resources.

### Source links

- [All Questions](https://www.aced.io/questions)
- [Aced home](https://www.aced.io/?src=nav)
- [Courses](https://www.aced.io/courses?src=nav)
- [Practice](https://www.aced.io/practice?src=nav)
- [Experiences](https://www.aced.io/experiences?src=nav)
- [Coaching](https://www.aced.io/coaching?src=nav)
- [Pricing](https://www.aced.io/upgrade?src=nav)

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F6008%2Ffind-median-from-data-stream&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F6008%2Ffind-median-from-data-stream). Opening a form does not execute a tool.