Skip to content

Latest commit

 

History

History
executable file
·
21 lines (11 loc) · 609 Bytes

Continuous_Median.md

File metadata and controls

executable file
·
21 lines (11 loc) · 609 Bytes

Continuous Median

Problem Statement

Write a class that can support the following two functionalities: 1) the continuous insertion of numbers and 2) the instant (O(1) time) retrieval of the median of the numbers that have been inserted thus far. The getMedian() method, which handles the retrieval of the median, has already been written for you. You simply have to write the insert() method.

Sample input: insert(5), insert(10), getMedian(), insert(100), getMedian() Sample output: -, -, 7.5, -, 10

Explanation

Solution

Check this Python code.