Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LargeNumber ¶
type LargeNumber []int
func (LargeNumber) Len ¶
func (this LargeNumber) Len() int
func (LargeNumber) Less ¶
func (this LargeNumber) Less(i, j int) bool
func (LargeNumber) Swap ¶
func (this LargeNumber) Swap(i, j int)
type MedianFinder ¶
type MedianFinder struct {
// contains filtered or unexported fields
}
295. Find Median from Data Stream
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. For example, for arr = [2,3,4], the median is 3. For example, for arr = [2,3], the median is (2 + 3) / 2 = 2.5. Implement the MedianFinder class:
- MedianFinder() initializes the MedianFinder 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. Answers within 10-5 of the actual answer will be accepted.
Runtime: 642 ms, faster than 65.93% of Go online submissions for Find Median from Data Stream. Memory Usage: 20.1 MB, less than 84.96% of Go online submissions for Find Median from Data Stream.
func Constructor4 ¶
func Constructor4() MedianFinder
func (*MedianFinder) AddNum ¶
func (this *MedianFinder) AddNum(num int)
func (*MedianFinder) FindMedian ¶
func (this *MedianFinder) FindMedian() float64
Click to show internal directories.
Click to hide internal directories.