Documentation
¶
Index ¶
- Constants
- func Abs(num int) int
- func Manhattan(x1 int, y1 int, x2 int, y2 int) int
- func Max[T cmp.Ordered](nums ...T) T
- func Min[T cmp.Ordered](nums ...T) T
- func Sum(nums ...int) int
- type BinaryMatrix
- type Cache
- type Cacheable
- type CustomStack
- type DoubleListNode
- type FindElements
- type FirstUnique
- type FoodItem
- type FoodItemsPQ
- type FoodRatings
- type IntHeap
- type IntSlice
- type KthLargest
- type ListNode
- type Logger
- type MRUQueue
- type MovingAverage
- type MyCalendar
- type MyCircularDeque
- func (deq *MyCircularDeque) DeleteFront() bool
- func (deq *MyCircularDeque) DeleteLast() bool
- func (deq *MyCircularDeque) GetFront() int
- func (deq *MyCircularDeque) GetRear() int
- func (deq *MyCircularDeque) InsertFront(value int) bool
- func (deq *MyCircularDeque) InsertLast(value int) bool
- func (deq *MyCircularDeque) IsEmpty() bool
- func (deq *MyCircularDeque) IsFull() bool
- type MyCircularQueue
- type MyHashMap
- type MyHashSet
- type MyQueue
- type Node
- type NumArray
- type NumberContainers
- type PairNode
- type ParkingSystem
- type ProductOfNumbers
- type Queue
- type Queueable
- type RandomizedSet
- type SeatManager
- type Set
- type Slice
- type Stack
- type Stackable
- type SticksPQ
- type TreeNode
- type TwoSum
- type ValidWordAbbr
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func Max ¶
Max returns maximum of `nums` of type `T` and have more friendly interface then build-in `max()`. Panics if `nums` have zero elements.
Types ¶
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 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 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 Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func LoggerConstructor ¶
func LoggerConstructor() Logger
type MRUQueue ¶
type MRUQueue struct {
// contains filtered or unexported fields
}
func MRUQueueConstructor ¶
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
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
type MyHashSet ¶
type MyHashSet struct {
// contains filtered or unexported fields
}
func MyHashSetConstructor ¶
func MyHashSetConstructor() MyHashSet
type MyQueue ¶
type MyQueue struct {
// contains filtered or unexported fields
}
func MyQueueConstructor ¶
func MyQueueConstructor() MyQueue
type NumArray ¶
type NumArray struct {
// contains filtered or unexported fields
}
func NumArrayConstructor ¶
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 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 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 TwoSum ¶
type TwoSum struct {
// contains filtered or unexported fields
}
func TwoSumConstructor ¶
func TwoSumConstructor() TwoSum
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
¶
- adddigits.go
- addspaces.go
- addstrings.go
- addtwonumbers.go
- amountoftime.go
- applyoperations.go
- arealmostequal.go
- aresentencessimilar.go
- arrangecoins.go
- arrayranktransform.go
- arraysign.go
- arraysintersection.go
- arraystringsareequal.go
- assignbikes_1.go
- assignbikes_2.go
- averageofsubtree.go
- averagewaitingtime.go
- backspacecompare.go
- bagoftokensscore.go
- balancedstringsplit.go
- binarygap.go
- binarytreepaths.go
- buddystrings.go
- buildarray_1.go
- buildarray_2.go
- buychoco.go
- cache.go
- calculatetime.go
- canarrange.go
- canattendmeetings.go
- canbeequal.go
- canbeincreasing.go
- canbevalid.go
- canchange.go
- canmakesubsequence.go
- canpartition.go
- canpermutepalindrome.go
- cansortarray.go
- canvisitallrooms.go
- canwinnim.go
- chalkreplacer.go
- check.go
- checkarithmeticsubarrays.go
- checkequaltree.go
- checkifexist.go
- checkifpangram.go
- checkinclusion.go
- checkonessegment.go
- checkpowersofthree.go
- cherrypickup.go
- cleardigits.go
- climbstairs.go
- clonegraph.go
- closestprimes.go
- closestrings.go
- coloredcells.go
- combinationsum2.go
- combinationsum3.go
- commonchars.go
- compareversion.go
- connectsticks.go
- const.go
- construct2darray.go
- containsnearbyduplicate.go
- convertdatetobinary.go
- converttemperature.go
- converttobase7.go
- converttotitle.go
- countbadpairs.go
- countcharacters.go
- countcomponents.go
- countconsistentstrings.go
- countdays.go
- countelements.go
- countfairpairs.go
- countgood.go
- countgoodtriplets.go
- counthomogenous.go
- countmatches.go
- countnicepairs.go
- countnodes.go
- countofsubstrings.go
- countpairs_1.go
- countpairs_2.go
- countpalindromicsubsequence.go
- countprefixsuffixpairs.go
- countsegments.go
- countseniors.go
- countservers.go
- countstudents.go
- countsubislands.go
- countsubstrings.go
- countsymmetricintegers.go
- countunguarded.go
- createbinarytree.go
- customsortstring.go
- customstack.go
- dailytemperatures.go
- daysbetweendates.go
- decode.go
- decrypt.go
- defangipaddr.go
- deleteduplicatesunsorted.go
- deletenode.go
- delnodes.go
- destcity.go
- diameterofbinarytree.go
- differenceofsums.go
- digitsum.go
- distinctintegers.go
- distinctnumbers.go
- dividearray_1.go
- dividearray_2.go
- divideplayers.go
- doesvalidarrayexist.go
- doubleit.go
- earliestacq.go
- eliminatemaximum.go
- equaldigitfrequency.go
- equalsubstring.go
- equaltodescendants.go
- eraseoverlapintervals.go
- evalrpn.go
- evaluatetree.go
- evenoddbit.go
- eventualsafenodes.go
- exist.go
- fib.go
- finalprices.go
- finalvalueafteroperations.go
- findarray.go
- findbottomleftvalue.go
- findcenter.go
- findcirclenum.go
- findcomplement.go
- findcontentchildren.go
- finddiagonalorder.go
- finddifferentbinarystring.go
- finddisappearednumbers.go
- finddistance.go
- findduplicatesubtrees.go
- findelements.go
- finderrornums.go
- findevennumbers.go
- findjudge.go
- findkthlargest.go
- findkthnumber.go
- findkthpositive.go
- findleastnumofuniqueints.go
- findlengthoflcis.go
- findlengthofshortestsubarray.go
- findlhs.go
- findmatrix.go
- findmaxaverage.go
- findmaxconsecutiveones_1.go
- findmaxconsecutiveones_2.go
- findmaxk.go
- findmaxlength.go
- findmediansortedarrays.go
- findmiddleindex.go
- findminarrowshots.go
- findmindifference.go
- findmissingandrepeatedvalues.go
- findmissingranges.go
- findmode.go
- findnumbers.go
- findpaths.go
- findpermutationdifference.go
- findrelativeranks.go
- findrestaurant.go
- findspecialinteger.go
- findthelongestsubstring.go
- findtheprefixcommonarray.go
- findthewinner.go
- findwinners.go
- findwords.go
- findwordscontaining.go
- firstcompleteindex.go
- firstpalindrome.go
- firstuniqchar.go
- firstunique.go
- foodratings.go
- foursumcount.go
- fractionaddition.go
- frequenciesofelements.go
- frequencysort_1.go
- frequencysort_2.go
- furthestbuilding.go
- gameresult.go
- garbagecollection.go
- generate.go
- generateabbreviations.go
- generatepossiblenextmoves.go
- getLongestSubsequence.go
- getaverages.go
- getcommon.go
- getconcatenation.go
- getdecimalvalue.go
- getdirections.go
- getfinalstate.go
- getfood.go
- gethappystring.go
- getintersectionnode.go
- getlastmoment.go
- getlucky.go
- getmaximumgenerated.go
- getmaximumgold.go
- getmaximumxor.go
- getrow.go
- getsneakynumbers.go
- getsumabsolutedifferences.go
- getwinner.go
- gridgame.go
- groupanagrams.go
- groupstrings.go
- halvesarealike.go
- hammingweight.go
- hascycle.go
- heightchecker.go
- imagesmoother.go
- inordersuccessor.go
- inordertraversal.go
- insert.go
- insertgreatestcommondivisors.go
- intersect.go
- intersection.go
- inverttree.go
- isaliensorted.go
- isanagram.go
- isarmstrong.go
- isarrayspecial.go
- isbalanced_1.go
- isbalanced_2.go
- iscircularsentence.go
- isevenoddtree.go
- ishappy.go
- isisomorphic.go
- ispalindrome_1.go
- ispalindrome_2.go
- ispathcrossing.go
- isperfectsquare.go
- ispoweroffour.go
- ispoweroftwo.go
- isprefixofword.go
- isprefixstring.go
- isreachableattime.go
- issametree.go
- isstrobogrammatic.go
- issubpath.go
- issubtree.go
- isugly.go
- isvalid.go
- isvalidpalindrome.go
- knightdialer.go
- kthcharacter.go
- kthdistinct.go
- kthgrammar.go
- kthlargest.go
- kweakestrows.go
- largestaltitude.go
- largestbstsubtree.go
- largestcombination.go
- largestdivisiblesubset.go
- largestgoodinteger.go
- largestnumber.go
- largestoddnumber.go
- largestperimeter.go
- largestuniquenumber.go
- lastvisitedintegers.go
- leafsimilar.go
- leastinterval.go
- leftmostcolumnwithone.go
- leftrightdifference.go
- lemonadechange.go
- lengthAfterTransformations.go
- lengthoflastword.go
- lengthoflis.go
- lengthoflongestsubstring.go
- lengthoflongestsubstringkdistinct.go
- lengthoflongestsubstringtwodistinct.go
- lettercombinations.go
- lexicalorder.go
- licensekeyformatting.go
- logger.go
- longestcommonsubsequence.go
- longestdiversestring.go
- longestmonotonicsubarray.go
- longestnicesubarray.go
- longestones.go
- longestpalindrome.go
- longestrepeatingsubstring.go
- longestsubarray.go
- luckynumbers.go
- majorityelement.go
- makeequal.go
- makeprefsumnonnegative.go
- matchplayersandtrainers.go
- math.go
- maxabsolutesum.go
- maxadjacentdistance.go
- maxancestordiff.go
- maxascendingsum.go
- maxcoins.go
- maxcount.go
- maxdepth.go
- maxdistance_1.go
- maxdistance_2.go
- maxequalrowsafterflips.go
- maxfrequency.go
- maxfrequencyelements.go
- maximumaveragesubtree.go
- maximumbeauty.go
- maximumcount.go
- maximumdifference.go
- maximumelementafterdecrementingandrearranging.go
- maximumgain.go
- maximumhappinesssum.go
- maximumlength.go
- maximumnumberofstringpairs.go
- maximumoddbinarynumber.go
- maximumpopulation.go
- maximumsum.go
- maximumuniquesubarray.go
- maxlength.go
- maxlengthbetweenequalcharacters.go
- maxmatrixsum.go
- maxnumberofballoons.go
- maxprobability.go
- maxproduct.go
- maxproductdifference.go
- maxrepeating.go
- maxscore.go
- maxsubarray.go
- maxsubarraylen.go
- maxsubarraylength.go
- maxsubsequence.go
- maxsum.go
- maxvowels.go
- maxwidthofverticalarea.go
- maxwidthramp.go
- merge.go
- mergearrays.go
- mergeinbetween.go
- mergenodes.go
- mergetrees.go
- middlenode.go
- minaddtomakevalid.go
- minbitflips.go
- minchanges.go
- mincost_1.go
- mincost_2.go
- mincostclimbingstairs.go
- mindifference.go
- mindistance.go
- mineatingspeed.go
- minend.go
- minfallingpathsum.go
- minheightshelves.go
- minimumabsdifference.go
- minimumchairs.go
- minimumdeletions.go
- minimumlength_1.go
- minimumlength_2.go
- minimumoperations_1.go
- minimumoperations_2.go
- minimumoperations_3.go
- minimumpushes.go
- minimumrecolors.go
- minimumrounds.go
- minimumsize.go
- minimumsteps.go
- minlength.go
- minmeetingrooms.go
- minmoves.go
- minoperations_1.go
- minoperations_2.go
- minoperations_3.go
- minoperations_4.go
- minoperations_5.go
- minoperations_6.go
- minoperations_7.go
- minoperations_8.go
- minpairsum.go
- minstartvalue.go
- minsteps_1.go
- minsteps_2.go
- minsubarraylen.go
- minswaps_1.go
- minswaps_2.go
- minswaps_3.go
- mintimetovisitallpoints.go
- mintotaldistance.go
- minwindow.go
- missingnumber.go
- missingrolls.go
- modifiedlist.go
- modifystring.go
- mostcommonword.go
- movezeroes.go
- movingaverage.go
- mruqueue.go
- mycalendar.go
- mycirculardeque.go
- mycircularqueue.go
- myhashmap.go
- myhashset.go
- myqueue.go
- mysqrt.go
- nearestpalindromic.go
- nodesbetweencriticalpoints.go
- nthuglynumber.go
- numarray.go
- numbercontainers.go
- numbercount.go
- numberofalternatinggroups.go
- numberofbeams.go
- numberofmatches.go
- numberofpairs.go
- numberofpatterns.go
- numberofsubstrings.go
- numbertowords.go
- numislands.go
- numklensubstrnorepeats.go
- nummagicsquaresinside.go
- numofsubarrays.go
- numrescueboats.go
- numrollstotarget.go
- numspecial.go
- numsquares.go
- numsubarrayproductlessthank.go
- numsubarrayswithsum.go
- numteams.go
- numtilepossibilities.go
- numwaterbottles.go
- numways_1.go
- numways_2.go
- onesminuszeros.go
- orarray.go
- parkingsystem.go
- partitionarray.go
- partitionlabels.go
- passthepillow.go
- pathsum.go
- pickgifts.go
- pivotarray.go
- pivotindex.go
- pivotinteger.go
- poorpigs.go
- possiblestringcount.go
- postorder.go
- postordertraversal.go
- prefixcount.go
- prefixesdivby5.go
- preordertraversal.go
- probabilityofheads.go
- productexceptself.go
- productofnumbers.go
- pseudopalindromicpaths.go
- queryresults.go
- queue.go
- randomizedset.go
- rangebitwiseand.go
- rangesum.go
- rangesumbst.go
- rearrangearray.go
- recoverfrompreorder.go
- reductionoperations.go
- reformatdate.go
- relativesortarray.go
- removedigit.go
- removeinterval.go
- removeleafnodes.go
- removenodes.go
- removenthfromend.go
- removeoccurrences.go
- removestones.go
- removevowels.go
- removezerosumsublists.go
- reorderlist.go
- repeatlimitedstring.go
- replacedigits.go
- restorearray.go
- restorematrix.go
- reverse.go
- reverselist.go
- reverseoddlevels.go
- reverseonlyletters.go
- reverseparentheses.go
- reverseprefix.go
- reversestr.go
- reversestring.go
- reversewords.go
- rob.go
- robotsim.go
- robotwithstring.go
- rotatestring.go
- runningsum.go
- scoreofstring.go
- search.go
- searchinsert.go
- seatmanager.go
- sequentialdigits.go
- set.go
- sharecandies.go
- shiftingletters.go
- shortestdistance.go
- shortestway.go
- shuffle.go
- smallestcommonelement.go
- smallestdistancepair.go
- smallestevenmultiple.go
- smallestnumber.go
- solution_1.go
- solution_2.go
- sortarray.go
- sortarraybyparity.go
- sortbybits.go
- sortcolors.go
- sortedsquares.go
- sortjumbled.go
- sortpeople.go
- sortvowels.go
- spiralmatrix.go
- spiralmatrixiii.go
- splitlisttoparts.go
- splitwordsbyseparator.go
- stack.go
- stonegameii.go
- strangeprinter.go
- stringmatching.go
- stringshift.go
- structs.go
- subsetxorsum.go
- sumofdigits.go
- sumofleftleaves.go
- sumofmultiples.go
- sumsubarraymins.go
- takecharacters.go
- themaximumachievablex.go
- thirdmax.go
- threeconsecutiveodds.go
- titletonumber.go
- toarray.go
- tohex.go
- tolowercase.go
- topkfrequent.go
- totalmoney.go
- transformarray.go
- transpose.go
- tree2str.go
- treetodoublylist.go
- triangletype.go
- tribonacci.go
- truncatesentence.go
- tuplesameproduct.go
- twooutofthree.go
- twosum_1.go
- twosum_2.go
- twosumlessthank.go
- uncommonfromsentences.go
- uniqueoccurrences.go
- uniquepaths.go
- validatebinarytreenodes.go
- validpalindrome.go
- validsquare.go
- validwordabbr.go
- validwordabbreviation.go
- validwordsquare.go
- vowelstrings.go
- wallsandgates.go
- waystosplitarray.go
- xorallnums.go
- xorqueries.go
Click to show internal directories.
Click to hide internal directories.