nc0101

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LFU

func LFU(operators [][]int, k int) (ans []int)

设计 LFU 缓存结构

Types

type Entry

type Entry struct {
	Key  int // 键
	Val  int // 值
	Freq int // 频率
}

type LfuCache

type LfuCache struct {
	// contains filtered or unexported fields
}

思路: 采用双 hash 表来记录数据

func NewLfuCache

func NewLfuCache(capacity int) *LfuCache

func (*LfuCache) Get

func (l *LfuCache) Get(key int) (value int)

func (*LfuCache) Set

func (l *LfuCache) Set(key, value int)

Jump to

Keyboard shortcuts

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