package
0.0.0-20250206101203-bd6683890685
Repository: https://github.com/dockerian/go-coding.git
Documentation: pkg.go.dev
# README
Coding Questions
Array
- find adjacent 1s in an integer matrix
- find duplicated number in an array contains n numbers ranging from 0 to n-2 | test
- find the best meetup point for all given points | test
- find the closest k points to a given point
- find the maximum sum of sequence in an integer array | test
- find the median in an integer array | test
- find the first available parking spot | test | solution
- find the second largest in an array | test
- find the single integer in an array where all other elements appear twice
- place N queens on NxN chessboard so that they can't attack each other | test | java
- sum of matrix diagonal items
Mathematics
String
- basic regular expression | test | java | js
- compress/decompress string | test
- convert string to integer | test
- find palindrome in string | test
- eval mathematical expressions (2-stack without parentheses grouping) | test
- find the longest subsequence in a string | test
- find the number of occurrences of the most frequent substring in a string | test
- justify a line of string text | test
- read link | test | js
- search trie | test
- reverse string | test
- reverse words | test
- sort array | test
Others
# Functions
CheckExpression checks if an expression has proper openings and closings of e.g.
CheckMatchedPair determines if a given pair, e.g.
Find2ndLargest returns the second largest in an array.
FindAjacent1s returns all coordinates "x,y" of adjacent 1s, where the position has adjacent 1s horizontally or vertically, from a matrix contains only 0s and 1s.
FindAvailableSpot returns first available spot from an array of occupied parking spot numbers in a parking garage which has parking spots 0..N (N could be infinite) note: in a design for real parking garage, a) the available spots should be thread-safe to support concurrency b) or to update first available info at any time before assigned.
FindDuplicate looks up for one duplicated number in an integer array contains n numbers ranging from 0 to n-2.
FindDuplicates returns a set of duplicated numbers in an integer array contains n numbers ranging from 0 to n-1.
FindMatchedSum returns index in input array of two items match to the sum.
FindMedian func Find the median (the middle value in an ordered integer list).
GetAllCases returns all variations of upper and lower cases.
GetLongestSubstringLength solves the following problem: Given a string, find the longest non-repeating substring length.
GetLongestSubstringUTF8 solves the following problem: Given a string, find the longest substring without repeating characters.
GetLongestUniqueSubstring solves the following problem: Given a string, find the longest substring without repeating characters.
GetMostFrequentRune returns the rune and count of the most appearance.
NewBasicRegex returns a pointer to a new BasicRegex object.
NewEval return a new instance of Eval struct.
PlaceQueens func Place N queens on NxN chessboard so that no two of them attack each other See https://developers.google.com/optimization/puzzles/queens.
Readlink normalizes a path string to remove extra '.' and '..'.
SumMaxtrixDiagonal returns both diagonal sum of up-left to down-right and up-right to down-left.
Translate returns Enlish words of a number.
# Type aliases
Queens type.