DIY: Find Median from a Data Stream

Solve the interview question "Find Median from a Data Stream" in this lesson.

We'll cover the following

Problem statement

You need to implement a data structure that will store a dynamically growing list of integers and provide efficient access to their median.

Coding exercise

You must implement the functions insert_num(num) and find_median(). The function insert_num(num) takes the parameter num, which is the number that you need to store. The function find_median() takes no parameter and will return the median of the stored numbers when it’s called.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.