** initialize your data structure here. */
()
| 54 | |
| 55 | /** initialize your data structure here. */ |
| 56 | func Constructor() MedianFinder { |
| 57 | minHeap := &MinHeap{} |
| 58 | maxHeap := &MaxHeap{} |
| 59 | heap.Init(minHeap) |
| 60 | heap.Init(maxHeap) |
| 61 | |
| 62 | return MedianFinder{ |
| 63 | largerHalf: minHeap, |
| 64 | smallerHalf: maxHeap, |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | func (this *MedianFinder) AddNum(num int) { |
| 69 | // push num onto the max heap for the smaller half of numbers |
no outgoing calls