solutions

package
v0.0.0-...-aed3393 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 14 Imported by: 0

Documentation ¶

Overview ¶

nolint

nolint:revive,stylecheck // das ist ok

Index ¶

Constants ¶

View Source
const SPACE = 2069

Variables ¶

This section is empty.

Functions ¶

func Abs ¶

func Abs(x int) int

Abs returns the absolute value of x.

func Contains ¶

func Contains[T comparable](xs []T, y T) bool

Contains return true if some collection `xs` contains element `y`

func GCD ¶

func GCD(p, q int) int

func LCM ¶

func LCM(p, q int) int

func LinkedListLen ¶

func LinkedListLen(n *ListNode) int

LinkedListLen returns amount on nodes in linked list (ListNode)

func Maximum ¶

func Maximum(xs ...int) int

Maximum returns maximum element of Int slice

func Minimum ¶

func Minimum(xs ...int) int

Minimum return minimum element of Int slice

func RemoveFromIntSlice ¶

func RemoveFromIntSlice(xs *[]int, k int)

RemoveFromIntSlice removes k-th element of Int slice in-place todo: wanna move to go2 with generics

func Sum ¶

func Sum(xs ...int) int

Sum returns the sum of Ints

Types ¶

type BITTree ¶

type BITTree []int

func (BITTree) Query ¶

func (t BITTree) Query(i int) int

func (BITTree) Update ¶

func (t BITTree) Update(i, x, n int)

type BSTIterator ¶

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

func NewBSTIterator ¶

func NewBSTIterator(root *TreeNode) BSTIterator

NewBSTIterator should call Constructor to pass LeetCode tests

func (*BSTIterator) HasNext ¶

func (i *BSTIterator) HasNext() bool

func (*BSTIterator) Next ¶

func (i *BSTIterator) Next() int

type Bag ¶

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

type Bags ¶

type Bags []Bag

func (Bags) IsEmpty ¶

func (bs Bags) IsEmpty() bool

func (Bags) Len ¶

func (bs Bags) Len() int

func (Bags) Less ¶

func (bs Bags) Less(i, j int) bool

func (*Bags) Pop ¶

func (bs *Bags) Pop() interface{}

func (*Bags) Push ¶

func (bs *Bags) Push(x interface{})

func (*Bags) Swap ¶

func (bs *Bags) Swap(i, j int)

type BrowserHistory ¶

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

func NewBrowserHistory ¶

func NewBrowserHistory(homepage string) BrowserHistory

NewBrowserHistory should call Constructor to pass LeetCode tests

func (*BrowserHistory) Back ¶

func (h *BrowserHistory) Back(steps int) string

func (*BrowserHistory) Forward ¶

func (h *BrowserHistory) Forward(steps int) string

func (*BrowserHistory) Visit ¶

func (h *BrowserHistory) Visit(url string)

type Bucket ¶

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

func (Bucket) Get ¶

func (b Bucket) Get(key int) int

func (*Bucket) Remove ¶

func (b *Bucket) Remove(key int)

func (*Bucket) Update ¶

func (b *Bucket) Update(key, value int)

type Buf1535 ¶

type Buf1535 struct {
	Arr []int
	Cur int
}

func (*Buf1535) Inc ¶

func (b *Buf1535) Inc()

func (*Buf1535) NextVal ¶

func (b *Buf1535) NextVal() int

func (*Buf1535) Swap ¶

func (b *Buf1535) Swap()

func (*Buf1535) Val ¶

func (b *Buf1535) Val() int

type Char ¶

type Char struct {
	Val rune
	P   int
}

type Codec ¶

type Codec struct{}

func NewCodec ¶

func NewCodec() Codec

NewCodec should call Constructor to pass LeetCode tests

type Coll ¶

type Coll []TMPair

func (*Coll) Add ¶

func (c *Coll) Add(p TMPair)

func (Coll) Get ¶

func (c Coll) Get(ts int) TMPair

type DDL ¶

type DDL struct {
	Val     string
	Back    *DDL
	Forward *DDL
}

type DLLNode ¶

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

DLLNode is double linked list node

type Deque ¶

type Deque[T any] []T

Deque is double ended queue

func (*Deque[T]) IsEmpty ¶

func (dq *Deque[T]) IsEmpty() bool

IsEmpty return false if queue is empty

func (*Deque[T]) PeekFirst ¶

func (dq *Deque[T]) PeekFirst() T

PeekFirst returns first element

func (*Deque[T]) PeekLast ¶

func (dq *Deque[T]) PeekLast() T

PeekLast returns element from the right

func (*Deque[T]) PopFirst ¶

func (dq *Deque[T]) PopFirst() T

PopFirst return and removes element from the left

func (*Deque[T]) PopLast ¶

func (dq *Deque[T]) PopLast() T

PopLast returns and removes element from the right

func (*Deque[T]) PushLast ¶

func (dq *Deque[T]) PushLast(x T)

PushLast adds element from the right

type Heap787 ¶

type Heap787 [][]int

func (*Heap787) Len ¶

func (h *Heap787) Len() int

func (*Heap787) Less ¶

func (h *Heap787) Less(i, j int) bool

func (*Heap787) Pop ¶

func (h *Heap787) Pop() any

func (*Heap787) Push ¶

func (h *Heap787) Push(x any)

func (*Heap787) Swap ¶

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

type IntMaxHeap ¶

type IntMaxHeap []int

IntMaxHeap Heap implementation for Ints (root is maximum: inverted Less)

func (*IntMaxHeap) Len ¶

func (h *IntMaxHeap) Len() int

func (*IntMaxHeap) Less ¶

func (h *IntMaxHeap) Less(i, j int) bool

func (*IntMaxHeap) Pop ¶

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

Pop removes the most small element of the heap from the heap end returns this element

func (*IntMaxHeap) Push ¶

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

Push adds element into heap

func (*IntMaxHeap) Swap ¶

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

type IntMinHeap ¶

type IntMinHeap []int

IntMinHeap Heap implementation for Ints (root is minimum)

func (*IntMinHeap) Len ¶

func (h *IntMinHeap) Len() int

func (*IntMinHeap) Less ¶

func (h *IntMinHeap) Less(i, j int) bool

func (*IntMinHeap) Pop ¶

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

Pop removes the most small element of the heap from the heap end returns this element

func (*IntMinHeap) Push ¶

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

Push adds element into heap

func (*IntMinHeap) Swap ¶

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

type Iterator ¶

type Iterator interface {
	// contains filtered or unexported methods
}

type KVPair ¶

type KVPair struct {
	Val, P int
}

type KthLargest ¶

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

func NewKthLargest ¶

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

NewKthLargest should call `Constructor` to pass LeetCode tests

func (*KthLargest) Add ¶

func (kl *KthLargest) Add(val int) int

type LFUCache ¶

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

func NewLFUCache ¶

func NewLFUCache(capacity int) LFUCache

NewLFUCache should call Constructor to pass LeetCode tests

func (*LFUCache) Get ¶

func (lfc *LFUCache) Get(key int) int

func (*LFUCache) Put ¶

func (lfc *LFUCache) Put(key, value int)

type LFUCacheElement ¶

type LFUCacheElement struct {
	Key  int
	Val  int
	Freq int
}

type LRUCache ¶

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

func NewLRUCache ¶

func NewLRUCache(capacity int) LRUCache

NewLRUCache should call Constructor for leetcode tests

func (*LRUCache) Get ¶

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

func (*LRUCache) Put ¶

func (lru *LRUCache) Put(key, value int)

type ListNode ¶

type ListNode struct {
	Val  int
	Next *ListNode
}

ListNode is licked list

func NewListNode ¶

func NewListNode(xs []int) *ListNode

NewListNode builds linked list of Ints from Ints slice

func (*ListNode) GetMiddle ¶

func (n *ListNode) GetMiddle() *ListNode

GetMiddle returns a middle node of linked list

func (*ListNode) String ¶

func (n *ListNode) String() string

func (*ListNode) ToSlice ¶

func (n *ListNode) ToSlice() []int

ToSlice accumulate linked list values and append them into int slice

type MPoint ¶

type MPoint []int

type MPointQ ¶

type MPointQ []MPoint

func (*MPointQ) IsEmpty ¶

func (q *MPointQ) IsEmpty() bool

func (*MPointQ) Len ¶

func (q *MPointQ) Len() int

func (*MPointQ) Pop ¶

func (q *MPointQ) Pop() MPoint

func (*MPointQ) Push ¶

func (q *MPointQ) Push(points ...MPoint)

type MaxHeap ¶

type MaxHeap []int

func (*MaxHeap) Len ¶

func (h *MaxHeap) Len() int

func (*MaxHeap) Less ¶

func (h *MaxHeap) Less(i, j int) bool

func (*MaxHeap) Pop ¶

func (h *MaxHeap) Pop() (v interface{})

func (*MaxHeap) Push ¶

func (h *MaxHeap) Push(v interface{})

func (*MaxHeap) Swap ¶

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

type MaxPairHeap767 ¶

type MaxPairHeap767 []*Pair767

func (*MaxPairHeap767) Len ¶

func (h *MaxPairHeap767) Len() int

func (*MaxPairHeap767) Less ¶

func (h *MaxPairHeap767) Less(i, j int) bool

func (*MaxPairHeap767) Pop ¶

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

func (*MaxPairHeap767) Push ¶

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

func (*MaxPairHeap767) Swap ¶

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

type MedianFinder ¶

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

func NewMedianFinder ¶

func NewMedianFinder() MedianFinder

NewMedianFinder should call Constructor to pass Leetcode tests

func (*MedianFinder) AddNum ¶

func (mf *MedianFinder) AddNum(num int)

func (*MedianFinder) FindMedian ¶

func (mf *MedianFinder) FindMedian() float64

type MinStack ¶

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

func NewMinStack ¶

func NewMinStack() MinStack

NewMinStack should call Constructor to pass LeetCode tests

func (*MinStack) GetMin ¶

func (s *MinStack) GetMin() int

func (*MinStack) Pop ¶

func (s *MinStack) Pop()

func (*MinStack) Push ¶

func (s *MinStack) Push(val int)

func (*MinStack) Top ¶

func (s *MinStack) Top() int

type MyCalendar ¶

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

func NewMyCalendar ¶

func NewMyCalendar() MyCalendar

NewMyCalendar should call Constructor to pass LeetCode tests

func (*MyCalendar) Book ¶

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

type MyCircularQueue ¶

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

func NewMyCircularQueue ¶

func NewMyCircularQueue(k int) MyCircularQueue

NewMyCircularQueue should call "Constructor" to pass LeetCode tests

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

func NewMyHashMap() MyHashMap

NewMyHashMap is Constructor for MyHashMap (it must call Constructor for LeetCode)

func (MyHashMap) Get ¶

func (m MyHashMap) Get(key int) int

func (*MyHashMap) Put ¶

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

func (*MyHashMap) Remove ¶

func (m *MyHashMap) Remove(key int)

type MyHashSet ¶

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

func NewMyHashSet ¶

func NewMyHashSet() MyHashSet

NewMyHashSet should call Constructor to pass LeetCode tests

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

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

func NewMyLinkedList ¶

func NewMyLinkedList() MyLinkedList

NewMyLinkedList should call Constructor to pass LeedCode tests

func (*MyLinkedList) AddAtHead ¶

func (l *MyLinkedList) AddAtHead(val int)

func (*MyLinkedList) AddAtIndex ¶

func (l *MyLinkedList) AddAtIndex(index, val int)

func (*MyLinkedList) AddAtTail ¶

func (l *MyLinkedList) AddAtTail(val int)

func (*MyLinkedList) DeleteAtIndex ¶

func (l *MyLinkedList) DeleteAtIndex(index int)

func (*MyLinkedList) Get ¶

func (l *MyLinkedList) Get(index int) int

func (MyLinkedList) String ¶

func (l MyLinkedList) String() string

type MyListNode ¶

type MyListNode struct {
	Val  int
	Next *MyListNode
}

type MyQueue225 ¶

type MyQueue225 []int

func (*MyQueue225) IsEmpty ¶

func (q *MyQueue225) IsEmpty() bool

func (*MyQueue225) Peek ¶

func (q *MyQueue225) Peek() int

func (*MyQueue225) Pop ¶

func (q *MyQueue225) Pop() int

func (*MyQueue225) Push ¶

func (q *MyQueue225) Push(x int)

func (*MyQueue225) Size ¶

func (q *MyQueue225) Size() int

type MyQueue232 ¶

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

func NewMyQueue232 ¶

func NewMyQueue232() MyQueue232

NewMyQueue232 should call Constructor to pass LeetCode tests

func (*MyQueue232) Empty ¶

func (q *MyQueue232) Empty() bool

func (*MyQueue232) Peek ¶

func (q *MyQueue232) Peek() int

func (*MyQueue232) Pop ¶

func (q *MyQueue232) Pop() int

func (*MyQueue232) Push ¶

func (q *MyQueue232) Push(x int)

type MyStack ¶

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

func NewMyStack ¶

func NewMyStack() MyStack

NewMyStack should call Constructor to pass LeetCode tests

func (*MyStack) Empty ¶

func (s *MyStack) Empty() bool

func (*MyStack) Pop ¶

func (s *MyStack) Pop() int

func (*MyStack) Push ¶

func (s *MyStack) Push(x int)

func (*MyStack) Top ¶

func (s *MyStack) Top() int

type NestedInteger ¶

type NestedInteger struct {
	Val    int
	Nested []*NestedInteger
}

func NewNestedInteger ¶

func NewNestedInteger() *NestedInteger

func (*NestedInteger) Add ¶

func (n *NestedInteger) Add(elem NestedInteger)

func (NestedInteger) GetInteger ¶

func (n NestedInteger) GetInteger() int

func (NestedInteger) GetList ¶

func (n NestedInteger) GetList() []*NestedInteger

func (NestedInteger) IsInteger ¶

func (n NestedInteger) IsInteger() bool

func (*NestedInteger) SetInteger ¶

func (n *NestedInteger) SetInteger(value int)

type NestedIterator ¶

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

func NewNestedIterator ¶

func NewNestedIterator(nestedList []*NestedInteger) *NestedIterator

NewNestedIterator should call Constructor to pass LeetCode tests

func (*NestedIterator) HasNext ¶

func (i *NestedIterator) HasNext() bool

func (*NestedIterator) Next ¶

func (i *NestedIterator) Next() int

type Node ¶

type Node struct {
	Val      int
	Left     *Node
	Right    *Node
	Next     *Node
	Parent   *Node
	Children []*Node
}

Node is just a node but with Next field

type Node427 ¶

type Node427 struct {
	Val         bool
	IsLeaf      bool
	TopLeft     *Node427
	TopRight    *Node427
	BottomLeft  *Node427
	BottomRight *Node427
}

type Num404s ¶

type Num404s map[int]bool

func (Num404s) Max ¶

func (n Num404s) Max() int

type NumArray ¶

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

func NewNumArray ¶

func NewNumArray(nums []int) NumArray

NewNumArray should call Constructor to pass Leetcode tests

func (*NumArray) SumRange ¶

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

func (*NumArray) Update ¶

func (a *NumArray) Update(index, val int)

type NumMatrix ¶

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

func NewNumMatrix ¶

func NewNumMatrix(matrix [][]int) NumMatrix

NewNumMatrix should call Constructor to pass LeetCode tests

func (*NumMatrix) SumRegion ¶

func (m *NumMatrix) SumRegion(row1, col1, row2, col2 int) int

type Orange ¶

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

type Pair ¶

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

type Pair767 ¶

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

type PeekingIterator ¶

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

func NewPeekingIterator ¶

func NewPeekingIterator(iter Iterator) *PeekingIterator

type Point ¶

type Point struct {
	X, Y int
	Dist float64
}

type Project ¶

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

type Q222 ¶

type Q222 []*TreeNode

func (Q222) IsEmpty ¶

func (q Q222) IsEmpty() bool

func (*Q222) Next ¶

func (q *Q222) Next() *TreeNode

func (*Q222) Push ¶

func (q *Q222) Push(n *TreeNode)

type Q429 ¶

type Q429 []*Node

func (*Q429) IsEmpty ¶

func (q *Q429) IsEmpty() bool

func (*Q429) Pop ¶

func (q *Q429) Pop() *Node

func (*Q429) Push ¶

func (q *Q429) Push(n *Node)

type Q637 ¶

type Q637 []*TreeNode

func (Q637) IsEmpty ¶

func (q Q637) IsEmpty() bool

func (Q637) Len ¶

func (q Q637) Len() int

func (*Q637) Pop ¶

func (q *Q637) Pop() *TreeNode

func (*Q637) Push ¶

func (q *Q637) Push(n *TreeNode)

func (Q637) Vals ¶

func (q Q637) Vals() []int

type Queue ¶

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

func (Queue) IsEmpty ¶

func (q Queue) IsEmpty() bool

func (*Queue) Pop ¶

func (q *Queue) Pop() *Node

func (*Queue) Push ¶

func (q *Queue) Push(n *Node)

type Queue1302 ¶

type Queue1302 []*TreeNode

func (*Queue1302) IsEmpty ¶

func (q *Queue1302) IsEmpty() bool

func (*Queue1302) Pop ¶

func (q *Queue1302) Pop() *TreeNode

func (*Queue1302) Push ¶

func (q *Queue1302) Push(x *TreeNode)

type Queue433 ¶

type Queue433 []string

func (*Queue433) IsEmpty ¶

func (q *Queue433) IsEmpty() bool

func (*Queue433) Len ¶

func (q *Queue433) Len() int

func (*Queue433) Pop ¶

func (q *Queue433) Pop() string

func (*Queue433) Push ¶

func (q *Queue433) Push(s string)

type Queue623 ¶

type Queue623 []*TreeNode

func (*Queue623) IsEmpty ¶

func (q *Queue623) IsEmpty() bool

func (*Queue623) Pop ¶

func (q *Queue623) Pop() *TreeNode

func (*Queue623) Push ¶

func (q *Queue623) Push(n *TreeNode)

type Queue994 ¶

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

func (Queue994) IsEmpty ¶

func (q Queue994) IsEmpty() bool

func (*Queue994) PopLeft ¶

func (q *Queue994) PopLeft() Orange

func (*Queue994) PushRight ¶

func (q *Queue994) PushRight(o Orange)

type RevIntHeap ¶

type RevIntHeap []int

func (RevIntHeap) Len ¶

func (h RevIntHeap) Len() int

func (RevIntHeap) Less ¶

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

func (*RevIntHeap) Pop ¶

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

Pop removes the most small element of the heap from the heap end returns this element

func (*RevIntHeap) Push ¶

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

Push adds element into heap

func (RevIntHeap) Swap ¶

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

type Ride ¶

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

type SeatManager ¶

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

func NewSeatManager ¶

func NewSeatManager(n int) SeatManager

NewSeatManager should call Constructor to pass Leetcode test

func (*SeatManager) Reserve ¶

func (sm *SeatManager) Reserve() int

func (*SeatManager) Unreserve ¶

func (sm *SeatManager) Unreserve(seatNumber int)

type Set ¶

type Set[K comparable] map[K]struct{}

Set represents a set data structure above of hashmap

func NewSet ¶

func NewSet[K comparable](xs []K) Set[K]

NewSet creates a new Set from slice of comparable elements. All doubles will be removed

func (Set[K]) Add ¶

func (s Set[K]) Add(k K)

Add adds element k into the Set

func (Set[K]) Contains ¶

func (s Set[K]) Contains(k K) bool

Contains returns true if Set contains element k

func (Set[K]) Remove ¶

func (s Set[K]) Remove(k K)

Remove removes element k form the Set

func (Set[K]) ToSlice ¶

func (s Set[K]) ToSlice() []K

ToSlice converts Set to slice

type SmallestInfiniteSet ¶

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

func NewSmallestInfiniteSet ¶

func NewSmallestInfiniteSet() SmallestInfiniteSet

NewSmallestInfiniteSet should call Constructor to pass LeetCode test

func (*SmallestInfiniteSet) AddBack ¶

func (s *SmallestInfiniteSet) AddBack(num int)

func (*SmallestInfiniteSet) PopSmallest ¶

func (s *SmallestInfiniteSet) PopSmallest() int

type Solution383 ¶

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

func NewSolution ¶

func NewSolution(head *ListNode) Solution383

NewSolution should call Constructor to pass LeetCode tests

func (*Solution383) GetRandom ¶

func (s *Solution383) GetRandom() int

type Stack1047 ¶

type Stack1047 []rune

func (*Stack1047) IsEmpty ¶

func (s *Stack1047) IsEmpty() bool

func (*Stack1047) Peek ¶

func (s *Stack1047) Peek() rune

func (*Stack1047) Pop ¶

func (s *Stack1047) Pop() rune

func (*Stack1047) Push ¶

func (s *Stack1047) Push(ch rune)

func (*Stack1047) ToSlice ¶

func (s *Stack1047) ToSlice() []rune

type Stack1544 ¶

type Stack1544 []rune

func (*Stack1544) IsEmpty ¶

func (s *Stack1544) IsEmpty() bool

func (*Stack1544) Peek ¶

func (s *Stack1544) Peek() rune

func (*Stack1544) Pop ¶

func (s *Stack1544) Pop() rune

func (*Stack1544) Push ¶

func (s *Stack1544) Push(r rune)

func (*Stack1544) ToSlice ¶

func (s *Stack1544) ToSlice() []rune

type Stack32 ¶

type Stack32 []int

func (*Stack32) IsEmpty ¶

func (s *Stack32) IsEmpty() bool

func (*Stack32) Peek ¶

func (s *Stack32) Peek() int

func (*Stack32) Pop ¶

func (s *Stack32) Pop() int

func (*Stack32) Push ¶

func (s *Stack32) Push(x int)

type Stack907 ¶

type Stack907 []int

func (Stack907) IsEmpty ¶

func (s Stack907) IsEmpty() bool

func (Stack907) Peek ¶

func (s Stack907) Peek() int

func (*Stack907) Pop ¶

func (s *Stack907) Pop()

func (*Stack907) Push ¶

func (s *Stack907) Push(x int)

type StockSpanner ¶

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

func NewStockSpanner ¶

func NewStockSpanner() StockSpanner

NewStockSpanner should call Constructor() to pass LeetCode tests

func (*StockSpanner) Next ¶

func (s *StockSpanner) Next(price int) int

type SummaryRanges ¶

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

func NewSummaryRanges ¶

func NewSummaryRanges() SummaryRanges

NewSummaryRanges should call Constructor to pass LeetCode test

func (*SummaryRanges) AddNum ¶

func (sr *SummaryRanges) AddNum(value int)

func (*SummaryRanges) GetIntervals ¶

func (sr *SummaryRanges) GetIntervals() [][]int

type TMPair ¶

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

type TimeMap ¶

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

func NewTimeMap ¶

func NewTimeMap() TimeMap

NewTimeMap should call Constructor to pass LeetCode tests

func (*TimeMap) Get ¶

func (tm *TimeMap) Get(key string, timestamp int) string

func (*TimeMap) Set ¶

func (tm *TimeMap) Set(key, value string, timestamp int)

type TreeNode ¶

type TreeNode = tn.TreeNode

TreeNode is just tn.TreeNode to save back compatibility

func FindTreeNode ¶

func FindTreeNode(n *TreeNode, v int) *TreeNode

FindTreeNode returns TreeNode with value v if it exist, otherwise - nil

func NewTreeNode ¶

func NewTreeNode(data string) *TreeNode

NewTreeNode creates a new TreeNode, ignores errors

type TreeNodeQ ¶

type TreeNodeQ []*TreeNode

TreeNodeQ is FIFO queue for TreeNode's

func (*TreeNodeQ) IsEmpty ¶

func (q *TreeNodeQ) IsEmpty() bool

IsEmpty return false if queue has no nodes

func (*TreeNodeQ) Len ¶

func (q *TreeNodeQ) Len() int

Len return amount of nodes in the queue

func (*TreeNodeQ) Pop ¶

func (q *TreeNodeQ) Pop() *TreeNode

Pop dequeued a node from the queue

func (*TreeNodeQ) Push ¶

func (q *TreeNodeQ) Push(nodes ...*TreeNode)

Push adds a node into the queue

type Trie ¶

type Trie[V any] struct {
	Val V
	// contains filtered or unexported fields
}

Trie is prefix tree

func NewTrie ¶

func NewTrie[V any]() *Trie[V]

NewTrie return Trie

func (*Trie[V]) Insert ¶

func (t *Trie[V]) Insert(key string, val V)

Insert adds val into Trie by key

func (*Trie[V]) StartsWith ¶

func (t *Trie[V]) StartsWith(prefix string) (*Trie[V], bool)

StartsWith returns true if Trie contains prefix

type Trie208 ¶

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

func Constructor ¶

func Constructor() Trie208

func NewTrie208 ¶

func NewTrie208(ch int32) *Trie208

func (*Trie208) Insert ¶

func (t *Trie208) Insert(word string)

func (*Trie208) Search ¶

func (t *Trie208) Search(word string) bool

func (*Trie208) StartsWith ¶

func (t *Trie208) StartsWith(prefix string) bool

type TrieNode1268 ¶

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

func (*TrieNode1268) DFSWithPrefix ¶

func (n *TrieNode1268) DFSWithPrefix(prefix string, acc *[]string)

func (*TrieNode1268) GetWordsStartingWith ¶

func (n *TrieNode1268) GetWordsStartingWith(prefix string) []string

func (*TrieNode1268) Insert ¶

func (n *TrieNode1268) Insert(s string)

func (*TrieNode1268) String ¶

func (n *TrieNode1268) String() string

type TrieNode211 ¶

type TrieNode211 struct {
	IsWord bool
	Next   map[rune]*TrieNode211
}

func NewTrieNode211 ¶

func NewTrieNode211() *TrieNode211

func (*TrieNode211) AddWord ¶

func (tn *TrieNode211) AddWord(word string)

func (*TrieNode211) Search ¶

func (tn *TrieNode211) Search(word string) bool

type TrieNode745 ¶

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

func NewTrieNode ¶

func NewTrieNode() *TrieNode745

type UndergroundSystem ¶

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

func NewUndergroundSystem ¶

func NewUndergroundSystem() UndergroundSystem

NewUndergroundSystem should call Constructor() to pass LeetCode tests

func (*UndergroundSystem) CheckIn ¶

func (s *UndergroundSystem) CheckIn(id int, stationName string, t int)

func (*UndergroundSystem) CheckOut ¶

func (s *UndergroundSystem) CheckOut(id int, stationName string, t int)

func (*UndergroundSystem) GetAverageTime ¶

func (s *UndergroundSystem) GetAverageTime(startStation, endStation string) float64

type Word692 ¶

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

type WordDictionary ¶

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

func NewWordDictionary ¶

func NewWordDictionary() WordDictionary

NewWordDictionary should call Constructor to pass LeeCode testa

func (*WordDictionary) AddWord ¶

func (wd *WordDictionary) AddWord(word string)

func (*WordDictionary) Search ¶

func (wd *WordDictionary) Search(word string) bool

type WordFilter ¶

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

func NewWordFilter ¶

func NewWordFilter(words []string) WordFilter

NewWordFilter should call Constructor to pass LeetCode tests

func (*WordFilter) F ¶

func (wf *WordFilter) F(prefix, suffix string) int

type WordHeap692 ¶

type WordHeap692 []Word692

func (*WordHeap692) Len ¶

func (w *WordHeap692) Len() int

func (*WordHeap692) Less ¶

func (w *WordHeap692) Less(i, j int) bool

func (*WordHeap692) Pop ¶

func (w *WordHeap692) Pop() any

func (*WordHeap692) Push ¶

func (w *WordHeap692) Push(x any)

func (*WordHeap692) Swap ¶

func (w *WordHeap692) Swap(i, j int)

Source Files ¶

Jump to

Keyboard shortcuts

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