golang

package
v0.0.0-...-b71b16c Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MOD              int = 1e9 + 7
	MaxInt32Overflow     = math.MaxInt32 / 10
	MinInt32Overflow     = math.MinInt32 / 10
)

Variables

This section is empty.

Functions

func Abs

func Abs(num int) int

func Manhattan

func Manhattan(x1 int, y1 int, x2 int, y2 int) int

func Max

func Max[T cmp.Ordered](nums ...T) T

Max returns maximum of `nums` of type `T` and have more friendly interface then build-in `max()`. Panics if `nums` have zero elements.

func Min

func Min[T cmp.Ordered](nums ...T) T

Min returns minimum of `nums` of type `T` and have more friendly interface then build-in `min()`. Panics if `nums` have zero elements.

func Sum

func Sum(nums ...int) int

Types

type BinaryMatrix

type BinaryMatrix interface {
	Get(row int, col int) int
	Dimensions() []int
}

type Cache

type Cache interface {
	Load(keys ...int) (int, bool)
	Save(val int, keys ...int)
}

func NewCache

func NewCache() Cache

type FoodItem

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

type FoodItemsPQ

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

func (*FoodItemsPQ) Len

func (pq *FoodItemsPQ) Len() int

func (*FoodItemsPQ) Less

func (pq *FoodItemsPQ) Less(i, j int) bool

func (*FoodItemsPQ) Pop

func (pq *FoodItemsPQ) Pop() interface{}

func (*FoodItemsPQ) Push

func (pq *FoodItemsPQ) Push(x interface{})

func (*FoodItemsPQ) Swap

func (pq *FoodItemsPQ) Swap(i, j int)

type FoodRatings

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

func FoodRatingsConstructor

func FoodRatingsConstructor(foods []string, cuisines []string, ratings []int) FoodRatings

func (*FoodRatings) ChangeRating

func (fr *FoodRatings) ChangeRating(food string, newRating int)

func (*FoodRatings) HighestRated

func (fr *FoodRatings) HighestRated(cuisine string) string

type IntHeap

type IntHeap []int

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() any

func (*IntHeap) Push

func (h *IntHeap) Push(x any)

func (*IntHeap) Swap

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

type ListNode

type ListNode struct {
	Val  int
	Next *ListNode
}

type Logger

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

func LoggerConstructor

func LoggerConstructor() Logger

func (*Logger) ShouldPrintMessage

func (l *Logger) ShouldPrintMessage(timestamp int, message string) bool

type MovingAverage

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

func MovingAverageConstructor

func MovingAverageConstructor(size int) MovingAverage

func (*MovingAverage) Next

func (ma *MovingAverage) Next(next int) float64

type MyQueue

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

func MyQueueConstructor

func MyQueueConstructor() MyQueue

func (*MyQueue) Empty

func (q *MyQueue) Empty() bool

func (*MyQueue) Peek

func (q *MyQueue) Peek() int

func (*MyQueue) Pop

func (q *MyQueue) Pop() int

func (*MyQueue) Push

func (q *MyQueue) Push(x int)

type NumArray

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

func NumArrayConstructor

func NumArrayConstructor(nums []int) NumArray

func (*NumArray) SumRange

func (na *NumArray) SumRange(left int, right int) int

type PairNode

type PairNode [2]int

type ParkingSystem

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

func ParkingSystemConstructor

func ParkingSystemConstructor(big int, medium int, small int) ParkingSystem

func (*ParkingSystem) AddCar

func (ps *ParkingSystem) AddCar(carType int) bool

type Queue

type Queue[T Queueable] interface {
	Enqueue(val T)
	Dequeue() (T, bool)
	Peek() (T, bool)
	Size() int
	IsEmpty() bool
}

func NewQueue

func NewQueue[T Queueable]() Queue[T]

type Queueable

type Queueable interface {
	~int | ~*TreeNode | PairNode
}

type RandomizedSet

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

func RandomizedSetConstructor

func RandomizedSetConstructor() RandomizedSet

func (*RandomizedSet) GetRandom

func (rs *RandomizedSet) GetRandom() int

func (*RandomizedSet) Insert

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

func (*RandomizedSet) Remove

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

type SeatManager

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

func SeatManagerConstructor

func SeatManagerConstructor(n int) SeatManager

func (*SeatManager) Reserve

func (sm *SeatManager) Reserve() int

func (*SeatManager) Unreserve

func (sm *SeatManager) Unreserve(seatNumber int)

type Set

type Set[T comparable] interface {
	Add(val T)
	Del(val T)
	Size() int
	Populate(vals ...T)
	Contains(val T) bool
	Values() []T
}

func NewSet

func NewSet[T comparable]() Set[T]

type Stack

type Stack[T Stackable] interface {
	Push(val T)
	Pop() (T, bool)
	Peek() (T, bool)
	Size() int
	IsEmpty() bool
}

func NewStack

func NewStack[T Stackable]() Stack[T]

type Stackable

type Stackable interface {
	~int | ~rune | ~*TreeNode | ~*ListNode
}

type SticksPQ

type SticksPQ []int

func (*SticksPQ) Len

func (pq *SticksPQ) Len() int

func (*SticksPQ) Less

func (pq *SticksPQ) Less(i, j int) bool

func (*SticksPQ) Pop

func (pq *SticksPQ) Pop() interface{}

func (*SticksPQ) Push

func (pq *SticksPQ) Push(x interface{})

func (*SticksPQ) Swap

func (pq *SticksPQ) Swap(i, j int)

type TreeNode

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

Source Files

Jump to

Keyboard shortcuts

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