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 insertNum(num)
and findMedian()
. The function insertNum(num)
takes the parameter num
, which is the number that you need to store. The function findMedian()
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 70+ hands-on prep courses.