Documentation ¶
Index ¶
- func AddWithoutPlus(a int, b int) (result int)
- func BestSplit(dictionary map[string]struct{}, sentence string) string
- func ComputeHistogramVolume(histogram []int) int
- func ComputeSimilarities(documents []Document) map[DocPair]float64
- func Count2sInRange(number int) int
- func FindLongestSubarray(array []rune) []rune
- func FindMajorityElement(values []int) int
- func FindMissing(array []int) int
- func GetKthMagicNumber(k int) int
- func GetLongestWord(words []string) string
- func MaxMinutesIterative(messages []int) int
- func MaxMinutesRecursive(messages []int) int
- func MissingTwo(array []int) []int
- func PickMRecursively(original []int, m int) []int
- func SearchAllSubstringsInString(big string, smalls []string) map[string][]int
- func ShuffleArray(array []int)
- func SmallestK(array []int, k int) []int
- func TransformWord(dictionary []string, source string, target string) []string
- func TrulyMostPopular(names map[string]int, synonyms [][]string) map[string]int
- type BitNode
- type DocPair
- type Document
- type HeightWidth
- type LocationPair
- type ParseResult
- type Range
- type RunningMedianCalculator
- type SubMatrix
- type SubSquare
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddWithoutPlus ¶
AddWithoutPlus adds 2 numbers without using the `+` sign
func ComputeHistogramVolume ¶
ComputeHistogramVolume goes through each bar and compute the volume of water above it. volume of water at the bar =
height - min(tallest bar on left, tallest bar on right) [where above equation is positive]
Compute the left max in the first sweep, then sweep again to compute the right max, minimum of the bar heights, and the delta
func ComputeSimilarities ¶
ComputeSimilarities computes the similarities between different words in the dictionary
func Count2sInRange ¶
Count2sInRange counts the number of 2s in a digit
func FindLongestSubarray ¶
FindLongestSubarray returns the longest subarray with equal letters and numbers
func FindMajorityElement ¶
FindMajorityElement finds an element in a list of elements which repeats more than 50% of the time
func FindMissing ¶
FindMissing returns the missing item from a list of integers from [0,n]
func GetKthMagicNumber ¶
GetKthMagicNumber finds the kth number such that the only prime factors are 3, 5, 7
func GetLongestWord ¶
GetLongestWord returns the longest word in a list made up of sub words.
func MaxMinutesIterative ¶
MaxMinutesIterative returns the max sequence without skipping
func MaxMinutesRecursive ¶
MaxMinutesRecursive returns the max sequence with skipping.
func MissingTwo ¶
MissingTwo returns the 2 missing numbers of the array ordered from 0 to N
func PickMRecursively ¶
PickMRecursively pics M elements from an array randomly
func SearchAllSubstringsInString ¶
SearchAllSubstringsInString returns all substring in a string
func TransformWord ¶
TransformWord shows the path for transforming a word from source to target.
Types ¶
type BitNode ¶
type BitNode struct {
// contains filtered or unexported fields
}
BitNode is a node with 2 links
func ConvertTreeToDoublyLinkedList ¶
ConvertTreeToDoublyLinkedList converts a list to a circular linked list and then breaks the circular connection
type DocPair ¶
type DocPair struct {
// contains filtered or unexported fields
}
DocPair is a pair of documents
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document represents a document of words
type HeightWidth ¶
type HeightWidth struct {
// contains filtered or unexported fields
}
HeightWidth is a struct having height and width
func LongestIncreasingSequence ¶
func LongestIncreasingSequence(items []HeightWidth) []HeightWidth
LongestIncreasingSequence returns the longest way in which items can be stacked on top of each other.
type LocationPair ¶
type LocationPair struct {
// contains filtered or unexported fields
}
LocationPair represents 2 locations
func FindClosest ¶
func FindClosest(word1, word2 string, locations map[string][]int) *LocationPair
FindClosest finds the closest distance between 2 words in a string
type ParseResult ¶
type ParseResult struct {
// contains filtered or unexported fields
}
ParseResult stores the result of parsing a string
type Range ¶
type Range struct {
// contains filtered or unexported fields
}
Range represents a range of numbers from start till small
func ShortestSuperSequence ¶
ShortestSuperSequence returns the shortest sequence of all the elements in `small` in the `big` array
type RunningMedianCalculator ¶
type RunningMedianCalculator struct {
// contains filtered or unexported fields
}
RunningMedianCalculator gets the running median for a stream of items
func NewRunningMedianCalculator ¶
func NewRunningMedianCalculator() RunningMedianCalculator
NewRunningMedianCalculator calculates the running median
func (*RunningMedianCalculator) Median ¶
func (calculator *RunningMedianCalculator) Median() float64
Median returns the running median
Source Files ¶
- 10_majority_element.go
- 11_word_distance.go
- 12_bit_node.go
- 13_re_space.go
- 14_smallest_k.go
- 15_longest_word.go
- 16_the_masseuse.go
- 17_multi_search.go
- 18_shortest_supersequence.go
- 19_missing_two.go
- 1_add_without_plus.go
- 20_continious_median.go
- 21_volume_of_histogram.go
- 22_word_transformer.go
- 23_max_square_matrix.go
- 24_max_submatrix.go
- 26_sparse_similarity.go
- 2_shuffle.go
- 3_random_set.go
- 4_missing_number.go
- 5_letters_and_numbers.go
- 6_count_of_2s.go
- 7_baby_names.go
- 8_circus_tower.go
- 9_kth_multiple.go