Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DecreaseQueue ¶
type DecreaseQueue[T constraints.Ordered] struct { // contains filtered or unexported fields }
单调递减队列,头部始终是最大值
func NewDecreaseQueue ¶
func NewDecreaseQueue[T constraints.Ordered]() *DecreaseQueue[T]
func (*DecreaseQueue[T]) Back ¶
func (q *DecreaseQueue[T]) Back() T
func (*DecreaseQueue[T]) Empty ¶
func (q *DecreaseQueue[T]) Empty() bool
func (*DecreaseQueue[T]) Front ¶
func (q *DecreaseQueue[T]) Front() T
func (*DecreaseQueue[T]) Push ¶
func (q *DecreaseQueue[T]) Push(val T)
func (*DecreaseQueue[T]) Size ¶
func (q *DecreaseQueue[T]) Size() int
type IHeap ¶
type IHeap [][2]int
使用go语言官方提供的接口实现小顶堆 用堆的好处是,如果使用快排,那么必须维护一样大小的数组 用堆,只用维护k大小的堆。(leetcode上不如快排快,可能是堆里面Pop和Push操作里面数组赋值太耗时。。。) 用小顶堆,维护k大小的堆,每次取出的是最小的,因此保留的都是更大的。
type MyStack ¶
type MyStack struct {
// contains filtered or unexported fields
}
func Constructor ¶
func Constructor() MyStack
Click to show internal directories.
Click to hide internal directories.