[Python] Logic Explained with 2 Heaps, Clean code.
\n"""\n        ## RC ##\n        ## APPROACH : 2 HEAPS ##\n        ## LOGIC ##\n        ## One minheap to store low values and second maxheap to store max value
```\n"""\n        ## RC ##\n        ## APPROACH : 2 HEAPS ##\n        ## LOGIC ##\n        ## One minheap to store low values and second maxheap to store max values, we keep track and update median every time after insertion ##\n        \n\t\t## TIME COMPLEXITY : O(logN) ##\n\t\t## SPACE COMPLEXITY : O(N) ##\n\n        ## EXAMPLE ##\n        Adding number 41\n        MaxHeap lo: [41]           // MaxHeap stores the largest value at the top (index 0)\n        MinHeap hi: []             // MinHeap stores the smallest value at the top (index 0)\n        Median is 41\n        =======================\n        Adding number 35\n        MaxHeap lo: [35]          // max heap stores smaller half of nums\n        MinHeap hi: [41]          // min heap stores bigger half of nums\n        Median is 38\n        =======================\n        Adding number 62\n        MaxHeap lo: [41, 35]\n        MinHeap hi: [62]\n        Median is 41\n        =======================\n        Adding number 4\n        MaxHeap lo: [35, 4]\n        MinHeap hi: [41, 62]\n        Median is 38\n        =======================\n        Adding number 97\n        MaxHeap lo: [41, 35, 4]\n        MinHeap hi: [62, 97]\n        Median is 41\n        =======================\n        Adding number 108\n        MaxHeap lo: [41, 35, 4]\n        MinHeap hi: [62, 97, 108]\n        Median is 51.5\n"""\n\nclass MedianFinder:\n    def __init__(self):\n        self.lo = []  \n        self.hi = []  \n\n    def addNum(self, num):\n        heappush(self.lo, -num)             # lo is maxheap, so -1 * num\n        heappush(self.hi, -self.lo[0])      # hi is minheap\n        heappop(self.lo)\n        \n        if len(self.lo) < len(self.hi):\n            heappush(self.lo, -self.hi[0])\n            heappop(self.hi)\n            \n    def findMedian(self):\n        if len(self.lo) > len(self.hi):\n            return -self.lo[0]                  \n        else:\n            return (self.hi[0] - self.lo[0]) / 2  # - as low has -ve values\n```\nPLEASE UPVOTE IF YOU LIKE MY SOLUTION
['Python', 'Python3']