Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/TheAlgorithms/Go
/ functions
Functions
1,378 in github.com/TheAlgorithms/Go
⨍
Functions
1,378
◇
Types & classes
127
↓ 1 callers
Function
CountChars
CountChars counts the number of a times a character has occurred in the provided string argument and returns a map with `rune` as keys and the count a
strings/charoccurrence.go:12
↓ 1 callers
Method
CreateChild
(NodeValue, int)
project_euler/problem_18/problem18.go:45
↓ 1 callers
Function
Decrypt
(cipherText string, rails int)
cipher/railfence/railfence.go:50
↓ 1 callers
Function
DefaultNew
DefaultNew returns a new HashMap instance with default values
structure/hashmap/hashmap.go:24
↓ 1 callers
Method
DelAtEnd
DelAtEnd deletes the snode at the tail(end) of the list and returns its value. Returns false if the list is empty.
structure/linkedlist/singlylinkedlist.go:65
↓ 1 callers
Method
Delete
Delete the current item.
structure/linkedlist/cyclic.go:74
↓ 1 callers
Function
DiceThrow
DiceThrow returns the number of ways to get sum `sum` using `m` dice with `n` faces
dynamic/dicethrow.go:10
↓ 1 callers
Method
Difference
Difference: gives new difference set of both sets. ex: [1,2,3] Difference [3,4,5] -> [1,2]
structure/set/set.go:47
↓ 1 callers
Method
Dijkstra
(start, end int)
graph/dijkstra.go:25
↓ 1 callers
Function
Distance
Distance Function that gives Levenshtein Distance
strings/levenshtein/levenshteindistance.go:10
↓ 1 callers
Function
Distance
(str1, str2 string)
strings/hamming/hammingdistance.go:18
↓ 1 callers
Function
Distance
Distance calculates the shortest distance between two points.
math/geometry/straightlines.go:18
↓ 1 callers
Function
Distance
Distance calculates the distance between to vectors with the Pythagoras theorem
math/pythagoras/pythagoras.go:15
↓ 1 callers
Function
EditDistanceDP
EditDistanceDP is an optimised implementation which builds on the ideas of the recursive implementation. We use dynamic programming to compute the DP
dynamic/editdistance.go:37
↓ 1 callers
Function
EdmondKarp
(graph WeightedGraph, source int, sink int)
graph/edmondkarp.go:43
↓ 1 callers
Function
EggDropping
EggDropping finds the minimum number of attempts needed to find the critical floor with `eggs` number of eggs and `floors` number of floors
dynamic/eggdropping.go:10
↓ 1 callers
Function
Encrypt
(text string, rails int)
cipher/railfence/railfence.go:13
↓ 1 callers
Function
FastInverseSqrt
FastInverseSqrt assumes that argument is always positive, and it does not deal with negative numbers. The "magic" number 0x5f3759df is hex for 1597463
math/binary/fast_inverse_sqrt.go:17
↓ 1 callers
Method
FindAllCycles
this function can do HasCycle() job but it is slower
graph/cycle.go:50
↓ 1 callers
Function
FindKthMax
FindKthMax returns the kth large element given an integer slice with nil `error` if found and returns -1 with `error` `search.ErrNotFound` if not foun
math/kthnumber.go:11
↓ 1 callers
Function
FindKthMin
FindKthMin returns kth small element given an integer slice with nil `error` if found and returns -1 with `error` `search.ErrNotFound` if not found. N
math/kthnumber.go:19
↓ 1 callers
Function
FindPath
Returns a mapping of vertices as path, if there is any from source to sink Otherwise, returns nil
graph/edmondkarp.go:16
↓ 1 callers
Function
FloydWarshall
FloydWarshall Returns all pair's shortest path using Floyd Warshall algorithm
graph/floydwarshall.go:17
↓ 1 callers
Function
GenerateElementSet
(out chan []string, n int)
math/permutation/heaps.go:42
↓ 1 callers
Function
GenerateParenthesis
(n int)
strings/generateparentheses/generateparentheses.go:12
↓ 1 callers
Function
GeneticString
GeneticString generates PopulationItem based on the imputed target string, and a set of possible runes to build a string with. In order to optimise st
strings/genetic/genetic.go:71
↓ 1 callers
Method
Get
Get a Node from the Binary-Search Tree
structure/tree/bstree.go:76
↓ 1 callers
Function
GetIdx
(target int, nodes []int)
graph/depthfirstsearch.go:9
↓ 1 callers
Method
GetLCA
(int, int)
graph/lowestcommonancestor.go:24
↓ 1 callers
Method
GetLCA
(u, v int)
graph/lowestcommonancestor.go:61
↓ 1 callers
Method
Has
Has Determines the tree has the node of Key
structure/tree/avl.go:89
↓ 1 callers
Method
HasSpace
()
project_euler/problem_18/problem18.go:42
↓ 1 callers
Function
Hash
Hash computes the SHA-1 hash of the input message
hashing/sha1/sha1.go:43
↓ 1 callers
Function
Hash
Hash computes the MD5 hash of the input message
hashing/md5/md5.go:63
↓ 1 callers
Method
Heapify
()
sort/heapsort.go:28
↓ 1 callers
Function
Heaps
Heap's Algorithm for generating all permutations of n objects
math/permutation/heaps.go:13
↓ 1 callers
Function
HuffDecode
HuffDecode recursively decodes the binary code in, by traversing the Huffman compression tree pointed by root. current stores the current node of the
compression/huffmancoding.go:106
↓ 1 callers
Function
HuffEncode
HuffEncode encodes the string in by applying the mapping defined by codes.
compression/huffmancoding.go:95
↓ 1 callers
Function
HuffEncoding
HuffEncoding recursively traverses the Huffman tree pointed by node to obtain the map codes, that associates a rune with a slice of booleans. Each cod
compression/huffmancoding.go:78
↓ 1 callers
Function
HuffTree
HuffTree returns the root Node of the Huffman tree by compressing listfreq. The compression produces the most optimal code lengths, provided listfreq
compression/huffmancoding.go:35
↓ 1 callers
Method
Init
(slice []Comparable)
sort/heapsort.go:17
↓ 1 callers
Method
InsertNonFull
(tree *BTree[T], key T)
structure/tree/btree.go:149
↓ 1 callers
Method
Intersection
Intersection: gives new intersection set of both sets. ex: [1,2,3] Intersection [3,4,5] -> [3]
structure/set/set.go:44
↓ 1 callers
Method
IsAlmostEqualTo
IsAlmostEqualTo verifies if two WeightedGraphs can be considered almost equal
graph/floydwarshall_test.go:17
↓ 1 callers
Function
IsArmstrong
(number int)
math/armstrong/isarmstrong.go:16
↓ 1 callers
Function
IsAutomorphic
(n T)
math/isautomorphic.go:16
↓ 1 callers
Function
IsInterleave
IsInterleave checks if string `s1` and `s2` can be interleaved to form string `s3`
dynamic/interleavingstrings.go:10
↓ 1 callers
Function
IsIsogram
(text string, order IsogramOrder)
strings/isisogram.go:34
↓ 1 callers
Function
IsLeapYear
(year int)
project_euler/problem_19/problem19.go:55
↓ 1 callers
Function
IsMatch
IsMatch checks if the string `s` matches the wildcard pattern `p`
dynamic/wildcardmatching.go:10
↓ 1 callers
Function
IsPalindromeRecursive
(text string)
strings/palindrome/ispalindrome.go:39
↓ 1 callers
Function
IsPangram
(text string)
strings/pangram/ispangram.go:21
↓ 1 callers
Function
IsParallel
IsParallel checks if two lines are parallel or not.
math/geometry/straightlines.go:42
↓ 1 callers
Function
IsPerpendicular
IsPerpendicular checks if two lines are perpendicular or not.
math/geometry/straightlines.go:47
↓ 1 callers
Function
IsSubsequence
Returns true if s is subsequence of t, otherwise return false.
strings/issubsequence.go:10
↓ 1 callers
Method
IsSubsetOf
(superSet Set[T])
structure/set/set.go:84
↓ 1 callers
Function
IsSubsetSum
(array []int, sum int)
dynamic/subsetsum.go:15
↓ 1 callers
Method
IsSupersetOf
(subSet Set[T])
structure/set/set.go:104
↓ 1 callers
Function
Iterative
Iterative Faster iterative version of GcdRecursive without holding up too much of the stack
math/gcd/gcditerative.go:7
↓ 1 callers
Function
JosephusProblem
https://en.wikipedia.org/wiki/Josephus_problem This is a struct-based solution for Josephus problem.
structure/linkedlist/cyclic.go:120
↓ 1 callers
Function
Kahn
Kahn's algorithm computes a topological ordering of a directed acyclic graph (DAG). `n` is the number of vertices, `dependencies` is a list of directe
graph/kahn.go:15
↓ 1 callers
Function
Kmp
Kmp Function kmp performing the Knuth-Morris-Pratt algorithm.
strings/kmp/kmp.go:4
↓ 1 callers
Method
Kosaraju
Kosaraju returns a list of Strongly Connected Components (SCCs).
graph/kosaraju.go:15
↓ 1 callers
Function
KruskalMST
(n int, edges []Edge)
graph/kruskal.go:23
↓ 1 callers
Method
Len
()
graph/prim.go:14
↓ 1 callers
Function
LongestArithmeticSubsequence
LongestArithmeticSubsequence returns the length of the longest arithmetic subsequence
dynamic/longestarithmeticsubsequence.go:10
↓ 1 callers
Function
LongestPalindrome
(s string)
strings/manacher/longestpalindrome.go:37
↓ 1 callers
Function
LongestPalindromicSubstring
LongestPalindromicSubstring returns the longest palindromic substring in the input string
dynamic/longestpalindromicsubstring.go:10
↓ 1 callers
Function
MaxCoins
MaxCoins returns the maximum coins we can collect by bursting the balloons
dynamic/burstballoons.go:6
↓ 1 callers
Method
MaxPathValueSearch
MaxPathValueSearch is a method that searches the maximum path value in a tree given a certain depth
project_euler/problem_18/tree.go:51
↓ 1 callers
Function
MaxSubArraySum
MaxSubArraySum returns the sum of the maximum subarray in the input array
dynamic/maxsubarraysum.go:12
↓ 1 callers
Function
MaxSubarraySum
MaxSubarraySum returns the maximum subarray sum
other/maxsubarraysum/maxsubarraysum.go:13
↓ 1 callers
Function
Mean
(values []T)
math/mean.go:7
↓ 1 callers
Function
Median
(values []T)
math/median.go:14
↓ 1 callers
Function
Merge
Merge Perform merge sort on a slice
sort/mergesort.go:47
↓ 1 callers
Function
MillerRabinDeterministic
MillerRabinDeterministic is a Deterministic version of the Miller-Rabin test, which returns correct results for all valid int64 numbers.
math/prime/millerrabintest.go:122
↓ 1 callers
Function
MillerRabinProbabilistic
MillerRabinProbabilistic is a probabilistic test for primality of an integer based of the algorithm devised by Miller and Rabin.
math/prime/millerrabintest.go:102
↓ 1 callers
Function
MillerRandomTest
MillerRandomTest This is the intermediate step that repeats within the miller rabin primality test for better probabilitic chances of receiving the co
math/prime/millerrabintest.go:78
↓ 1 callers
Function
Mode
(numbers []T)
math/mode.go:21
↓ 1 callers
Function
MoserDeBruijnSequence
(number int)
math/moserdebruijnsequence/sequence.go:9
↓ 1 callers
Function
Multiply64BitInt
Multiply64BitInt Checking if the integer multiplication overflows
math/modular/exponentiation.go:53
↓ 1 callers
Function
Naive
Implementation of naive string search O(n*m) where n=len(txt) and m=len(pattern)
strings/search/naive.go:5
↓ 1 callers
Function
New
New creates a new HashMap instance with the specified size and capacity
structure/hashmap/hashmap.go:32
↓ 1 callers
Method
NewCapacity
NewCapacity function increase the Capacity
structure/dynamicarray/dynamicarray.go:96
↓ 1 callers
Function
NewFenwickTree
NewFenwickTree creates a new Fenwick tree, initializes bit with the values of the array. Note that the queries and updates should have one based index
structure/fenwicktree/fenwicktree.go:20
↓ 1 callers
Function
NewLFU
NewLFU init the LFU cache with capacity
cache/lfu.go:33
↓ 1 callers
Function
NewSegmentTree
NewSegmentTree returns a new instance of a SegmentTree. It takes an input array of integers representing Array, initializes and builds the SegmentTree
structure/segmenttree/segmenttree.go:117
↓ 1 callers
Function
NewSqrtDecomposition
Create a new SqrtDecomposition instance with the parameters as specified by SqrtDecomposition comment Assumptions: - len(elements) > 0
sqrt/sqrtdecomposition.go:34
↓ 1 callers
Function
NextPermutation
(nums []int)
math/permutation/next_permutation.go:10
↓ 1 callers
Function
NotExist
(target int, slice []int)
graph/depthfirstsearch.go:18
↓ 1 callers
Function
NthCatalanNumber
NthCatalan returns the n-th Catalan Number Complexity: O(n²)
dynamic/catalan.go:15
↓ 1 callers
Function
OptimalBST
OptimalBST returns the minimum cost of constructing a Binary Search Tree
dynamic/optimalbst.go:6
↓ 1 callers
Function
Parenthesis
Parenthesis algorithm checks if every opened parenthesis is closed correctly. When parcounter is less than 0 when a closing parenthesis is detected wi
strings/parenthesis/parenthesis.go:8
↓ 1 callers
Function
PartitionProblem
PartitionProblem checks whether the given set can be partitioned into two subsets such that the sum of the elements in both subsets is the same.
dynamic/partitionproblem.go:11
↓ 1 callers
Method
Peek
Peak is return last value that insert into our stack
structure/stack/stacklinkedlistwithlist.go:28
↓ 1 callers
Function
PointDistance
PointDistance calculates the distance of a given Point from a given line. The slice should contain the coefficiet of x, the coefficient of y and the c
math/geometry/straightlines.go:53
↓ 1 callers
Method
Pop
()
sort/heapsort.go:37
↓ 1 callers
Method
Pop
Pop removes the minimum element (according to Less) from the heap. The complexity is O(log n) where n = h.Len().
structure/heap/heap.go:48
↓ 1 callers
Method
Pop
()
graph/prim.go:22
↓ 1 callers
Method
PrimMST
(start Vertex)
graph/prim.go:30
← previous
next →
401–500 of 1,378, ranked by callers