leetcode

package
v0.0.0-...-250739b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Intervals

type Intervals [][]int

func (Intervals) Len

func (x Intervals) Len() int

func (Intervals) Less

func (x Intervals) Less(i, j int) bool

func (Intervals) Swap

func (x Intervals) Swap(i, j int)

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 ListArray

type ListArray []*ListNode

func (ListArray) Len

func (this ListArray) Len() int

func (ListArray) Less

func (this ListArray) Less(i, j int) bool

func (ListArray) Swap

func (this ListArray) Swap(i, j int)

type ListNode

type ListNode = structure.ListNode

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

type TreeNode

type TreeNode = structure.TreeNode

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL