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(obj, num) and find_median(obj). The function insert_num(obj, num) takes the parameters num, which is the number that you need to store along with the struct object, obj. The function find_median(obj) only takes the struct obj as its parameter and will return the median of the stored numbers when it’s called.

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