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
Check this Python code.