golang

package
v0.0.0-...-bd5f7e2 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: MIT Imports: 15 Imported by: 0

Documentation ¶

Index ¶

Constants ¶

View Source
const (
	MOD              int = 1e9 + 7
	MaxInt32Overflow     = math.MaxInt32 / Digits
	MinInt32Overflow     = math.MinInt32 / Digits
	Smoke1               = "smoke 1"
	Smoke2               = "smoke 2"
	Smoke3               = "smoke 3"
	Digits               = 10
	Alphabet             = 26
	Byte                 = 255
	Base7                = 7
	Base2                = 2
	Half                 = 2
	Double               = 2
)

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 struct {
	// contains filtered or unexported fields
}

func NewCache ¶

func NewCache() *Cache

func (*Cache) Load ¶

func (c *Cache) Load(keys ...int) (int, bool)

func (*Cache) Save ¶

func (c *Cache) Save(val int, keys ...int)

type Cacheable ¶

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

type CustomStack ¶

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

func CustomStackConstructor ¶

func CustomStackConstructor(maxSize int) CustomStack

func (*CustomStack) Increment ¶

func (cs *CustomStack) Increment(k int, val int)

func (*CustomStack) Pop ¶

func (cs *CustomStack) Pop() int

func (*CustomStack) Push ¶

func (cs *CustomStack) Push(x int)

type DoubleListNode ¶

type DoubleListNode struct {
	Val  int
	Next *DoubleListNode
	Prev *DoubleListNode
}

type FindElements ¶

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

func FindElementsConstructor ¶

func FindElementsConstructor(root *TreeNode) FindElements

func (*FindElements) Find ¶

func (fe *FindElements) Find(target int) bool

type FirstUnique ¶

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

func FirstUniqueConstructor ¶

func FirstUniqueConstructor(nums []int) FirstUnique

func (*FirstUnique) Add ¶

func (fu *FirstUnique) Add(value int)

func (*FirstUnique) ShowFirstUnique ¶

func (fu *FirstUnique) ShowFirstUnique() int

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

func (*FoodItemsPQ) Push ¶

func (pq *FoodItemsPQ) Push(x any)

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 IntSlice ¶

type IntSlice []int

func (*IntSlice) Len ¶

func (ints *IntSlice) Len() int

func (*IntSlice) Less ¶

func (ints *IntSlice) Less(i, j int) bool

func (*IntSlice) Pop ¶

func (ints *IntSlice) Pop() any

func (*IntSlice) Push ¶

func (ints *IntSlice) Push(x any)

func (*IntSlice) Swap ¶

func (ints *IntSlice) Swap(i, j int)

type KthLargest ¶

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

func KthLargestConstructor ¶

func KthLargestConstructor(k int, nums []int) KthLargest

func (*KthLargest) Add ¶

func (kth *KthLargest) Add(val int) 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 MRUQueue ¶

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

func MRUQueueConstructor ¶

func MRUQueueConstructor(n int) MRUQueue

func (*MRUQueue) Fetch ¶

func (q *MRUQueue) Fetch(k int) int

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 MyCalendar ¶

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

func MyCalendarConstructor ¶

func MyCalendarConstructor() MyCalendar

func (*MyCalendar) Book ¶

func (m *MyCalendar) Book(start int, end int) bool

type MyCircularDeque ¶

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

func MyCircularDequeConstructor ¶

func MyCircularDequeConstructor(k int) MyCircularDeque

func (*MyCircularDeque) DeleteFront ¶

func (deq *MyCircularDeque) DeleteFront() bool

func (*MyCircularDeque) DeleteLast ¶

func (deq *MyCircularDeque) DeleteLast() bool

func (*MyCircularDeque) GetFront ¶

func (deq *MyCircularDeque) GetFront() int

func (*MyCircularDeque) GetRear ¶

func (deq *MyCircularDeque) GetRear() int

func (*MyCircularDeque) InsertFront ¶

func (deq *MyCircularDeque) InsertFront(value int) bool

func (*MyCircularDeque) InsertLast ¶

func (deq *MyCircularDeque) InsertLast(value int) bool

func (*MyCircularDeque) IsEmpty ¶

func (deq *MyCircularDeque) IsEmpty() bool

func (*MyCircularDeque) IsFull ¶

func (deq *MyCircularDeque) IsFull() bool

type MyCircularQueue ¶

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

func MyCircularQueueConstructor ¶

func MyCircularQueueConstructor(k int) MyCircularQueue

func (*MyCircularQueue) DeQueue ¶

func (q *MyCircularQueue) DeQueue() bool

func (*MyCircularQueue) EnQueue ¶

func (q *MyCircularQueue) EnQueue(value int) bool

func (*MyCircularQueue) Front ¶

func (q *MyCircularQueue) Front() int

func (*MyCircularQueue) IsEmpty ¶

func (q *MyCircularQueue) IsEmpty() bool

func (*MyCircularQueue) IsFull ¶

func (q *MyCircularQueue) IsFull() bool

func (*MyCircularQueue) Rear ¶

func (q *MyCircularQueue) Rear() int

type MyHashMap ¶

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

func MyHashMapConstructor ¶

func MyHashMapConstructor() MyHashMap

func (*MyHashMap) Get ¶

func (m *MyHashMap) Get(key int) int

func (*MyHashMap) Put ¶

func (m *MyHashMap) Put(key int, value int)

func (*MyHashMap) Remove ¶

func (m *MyHashMap) Remove(key int)

type MyHashSet ¶

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

func MyHashSetConstructor ¶

func MyHashSetConstructor() MyHashSet

func (*MyHashSet) Add ¶

func (s *MyHashSet) Add(key int)

func (*MyHashSet) Contains ¶

func (s *MyHashSet) Contains(key int) bool

func (*MyHashSet) Remove ¶

func (s *MyHashSet) Remove(key int)

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 Node ¶

type Node struct {
	Val      int
	Children []*Node
}

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 NumberContainers ¶

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

func NumberContainersConstructor ¶

func NumberContainersConstructor() NumberContainers

func (*NumberContainers) Change ¶

func (nc *NumberContainers) Change(index int, number int)

func (*NumberContainers) Find ¶

func (nc *NumberContainers) Find(number 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 ProductOfNumbers ¶

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

func ProductOfNumbersConstructor ¶

func ProductOfNumbersConstructor() ProductOfNumbers

func (*ProductOfNumbers) Add ¶

func (p *ProductOfNumbers) Add(num int)

func (*ProductOfNumbers) GetProduct ¶

func (p *ProductOfNumbers) GetProduct(k int) int

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 | ~[]int
}

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 Slice ¶

type Slice []int

func (*Slice) Len ¶

func (ints *Slice) Len() int

func (*Slice) Less ¶

func (ints *Slice) Less(i, j int) bool

func (*Slice) Pop ¶

func (ints *Slice) Pop() any

func (*Slice) Push ¶

func (ints *Slice) Push(x any)

func (*Slice) Swap ¶

func (ints *Slice) Swap(i, j int)

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 | ~string | ~*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() any

func (*SticksPQ) Push ¶

func (pq *SticksPQ) Push(x any)

func (*SticksPQ) Swap ¶

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

type TreeNode ¶

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

type TwoSum ¶

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

func TwoSumConstructor ¶

func TwoSumConstructor() TwoSum

func (*TwoSum) Add ¶

func (s *TwoSum) Add(number int)

func (*TwoSum) Find ¶

func (s *TwoSum) Find(value int) bool

type ValidWordAbbr ¶

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

func ValidWordAbbrConstructor ¶

func ValidWordAbbrConstructor(dictionary []string) ValidWordAbbr

func (*ValidWordAbbr) IsUnique ¶

func (abbr *ValidWordAbbr) IsUnique(word string) bool

Source Files ¶

Jump to

Keyboard shortcuts

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