Search
⌘K

Leetcode 295. Find Median from Data Stream

Maintain a data structure that supports adding integers from a stream and returning the current median efficiently for many interleaved addNum and findMedian calls. The core challenge is to keep the lower and upper halves balanced (e.g., two heaps) for fast updates and median retrieval, with follow-up optimizations using counting/frequency arrays when values lie in or mostly within a small fixed range.

Asked at:

Meta

Amazon

Amazon


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid January, 2026

Amazon

Amazon

Mid-level

Early December, 2025

Meta

Manager

I wasn't able to solve it. Expecting someone in management for a while to solve a leetcode hard like this is unreasonable imo. This has to be seen before to be answered... at least felt like that to me.

Late January, 2025

Meta

Staff

Comments

Your account is free and you can post anonymously if you choose.