ds

package
v0.0.0-...-1481d1c Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstUniqueNumber

func FirstUniqueNumber(nums []int, number int) int

*

  • @param nums: a continuous stream of numbers
  • @param number: a number
  • @return: returns the first unique number

func NthUglyNumber

func NthUglyNumber(n int) int

*

  • @param n: An integer
  • @return: return a integer as description.

func NthUglyNumber2

func NthUglyNumber2(n int) int

Types

type DataStream

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

func NewDataStream

func NewDataStream() *DataStream

func (*DataStream) Add

func (ds *DataStream) Add(num int)

func (*DataStream) FirstUnique

func (ds *DataStream) FirstUnique() int

type IntHeap

type IntHeap []int

An IntHeap is a min-heap of ints.

func (IntHeap) Len

func (h IntHeap) Len() int

func (IntHeap) Less

func (h IntHeap) Less(i, j int) bool

func (*IntHeap) Pop

func (h *IntHeap) Pop() interface{}

func (*IntHeap) Push

func (h *IntHeap) Push(x interface{})

func (IntHeap) Swap

func (h IntHeap) Swap(i, j int)

type LRUCache

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

func NewLRUCache

func NewLRUCache(capacity int) *LRUCache

func (*LRUCache) Get

func (c *LRUCache) Get(key int) int

func (*LRUCache) Set

func (c *LRUCache) Set(key, value int)

type RandomizedSet

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

func NewRandomizedSet

func NewRandomizedSet() *RandomizedSet

func (*RandomizedSet) GetRandom

func (this *RandomizedSet) GetRandom() int

GetRandom get a random element from the set

func (*RandomizedSet) Insert

func (this *RandomizedSet) Insert(val int) bool

Insert inserts a value to the set Returns true if the set did not already contain the specified element

func (*RandomizedSet) Remove

func (this *RandomizedSet) Remove(val int) bool

Remove removes a value from the set Returns true if the set contained the specified element

Jump to

Keyboard shortcuts

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