The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value, and the median is the mean of the two middle values. Implement the `MedianFinder` class: `MedianFinder()` initializes the object. `void addNum(int num)` adds the integer `num` from the data stream to the data structure. `double findMedian()` returns the median of all elements so far.
Two Heaps (Balance Principle)
We can divide the numbers into two halves: the smaller half (stored in a max-heap) and the larger half (stored in a min-heap). The max-heap gives us the largest element of the small half, and the min-heap gives us the smallest element of the large half. By keeping the heap sizes within 1 of each other, the median will always be either the root of the larger heap (if sizes are unequal) or the average of both roots (if sizes are equal).