How to solve this followup interview question?
Anonymous User
899

Was asked to solve https://leetcode.com/problems/find-median-from-data-stream/ first and then there was a follow-up question which I could not answer very well. The follow up is as follows:

"Let us assume that we have an infinite stream of numbers and we see each element exactly once. We have n slots in memory. We want to ensure that each event from the data stream has an equal probability of being included in the n slots. This is assuming that the median is that of the n selected elements. How would you do this?"

Any ideas here? I got rejected for the position but definitely would love to know how I could have answered this follow-up.

Comments (5)