MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / Constructor

Function Constructor

find_median_from_data_stream_295/solution.go:56–66  ·  view source on GitHub ↗

** initialize your data structure here. */

()

Source from the content-addressed store, hash-verified

54
55/** initialize your data structure here. */
56func 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
68func (this *MedianFinder) AddNum(num int) {
69 // push num onto the max heap for the smaller half of numbers

Callers 2

TestMedianFinder_0Function · 0.70
TestMedianFinder_1Function · 0.70

Calls

no outgoing calls

Tested by 2

TestMedianFinder_0Function · 0.56
TestMedianFinder_1Function · 0.56