Documentation
¶
Index ¶
- Variables
- func Abs(a int) int
- func DeleteFromIntSlice(a []int, target int) []int
- func FloatEquals(a, b float64) bool
- func InorderTraversal(root *TreeNode) []int
- func IsEqual(l, r *TreeNode) bool
- func IsEqualList(h1, h2 *ListNode) bool
- func LevelOrderTravesal(root *TreeNode) []int
- func LowerBound(nums []int, target int) int
- func Max(a, b int) int
- func Maxf(a, b float64) float64
- func Min(a, b int) int
- func NumOfOnes(a int) int
- func PostorderTraversal(root *TreeNode) []int
- func Pow(base, exp int) int
- func PreorderTraversal(root *TreeNode) []int
- func Upperbound(nums []int, target int) int
- type DNode
- type Deque
- func (deq *Deque) Back() interface{}
- func (deq *Deque) Front() interface{}
- func (deq *Deque) IsEmpty() bool
- func (deq *Deque) PopBack() interface{}
- func (deq *Deque) PopFront() interface{}
- func (deq *Deque) PushBack(val interface{})
- func (deq *Deque) PushFront(val interface{})
- func (deq *Deque) String() string
- type Graph
- type Int64PriorityQueue
- type ListNode
- type ListNodePriorityQueue
- type Queue
- type RTrie
- type Stack
- type StringHeap
- type TSTNode
- type TernarySearchTrie
- func (t *TernarySearchTrie) Contains(key string) bool
- func (t *TernarySearchTrie) Get(key string) interface{}
- func (t *TernarySearchTrie) LongestPrefixOf(query string) string
- func (t *TernarySearchTrie) Put(key string, val interface{})
- func (t *TernarySearchTrie) WithPrefix(query string) []interface{}
- type TreeNode
- type TrieNode
- type TuplePriorityQueue
Constants ¶
This section is empty.
Variables ¶
var EPSILON float64 = 0.00001
Functions ¶
func DeleteFromIntSlice ¶
DeleteFromIntSlice delete target from slice a
func FloatEquals ¶
func InorderTraversal ¶
InorderTraversal uses Morris Traversal Algorithm time complexity is O(n) and space complexity is O(1)
func LevelOrderTravesal ¶
func LowerBound ¶
LowerBound returns the lowest pos for target in the sorted array
func PostorderTraversal ¶
PostorderTraversal uses Morris Traversal Algorithm time complexity is O(n) and space complexity is O(1)
func PreorderTraversal ¶
PreorderTraversal uses Morris Traversal Algorithm time complexity is O(n) and space complexity is O(1)
func Upperbound ¶
Upperbound find the proper posion for target in nums, time complexity O(log(N))
Types ¶
type DNode ¶
type DNode struct { Val interface{} Prev, Next *DNode }
DNode represents the double linked node
type Deque ¶
type Deque struct {
// contains filtered or unexported fields
}
Deque is the double ended queue
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph represent a graph
func ConstructAdjacencyList ¶
ConstructAdjacencyList create an adjacency list based on the connections array
type Int64PriorityQueue ¶
type Int64PriorityQueue []int64
func (Int64PriorityQueue) Len ¶
func (pq Int64PriorityQueue) Len() int
func (Int64PriorityQueue) Less ¶
func (pq Int64PriorityQueue) Less(i, j int) bool
func (*Int64PriorityQueue) Pop ¶
func (pq *Int64PriorityQueue) Pop() interface{}
func (*Int64PriorityQueue) Push ¶
func (pq *Int64PriorityQueue) Push(x interface{})
func (Int64PriorityQueue) Swap ¶
func (pq Int64PriorityQueue) Swap(i, j int)
func (Int64PriorityQueue) Top ¶
func (pq Int64PriorityQueue) Top() int64
type ListNode ¶
ListNode is a node structure in a list
func ConstructFromSlice ¶
ConstructFromSlice returns a *ListNode built by s
func ConstructFromSliceWithCycle ¶
ConstructFromSliceWithCycle returns a ListNode with cycle.
type ListNodePriorityQueue ¶
type ListNodePriorityQueue []*ListNode
func (ListNodePriorityQueue) Len ¶
func (pq ListNodePriorityQueue) Len() int
func (ListNodePriorityQueue) Less ¶
func (pq ListNodePriorityQueue) Less(i, j int) bool
func (*ListNodePriorityQueue) Pop ¶
func (pq *ListNodePriorityQueue) Pop() interface{}
func (*ListNodePriorityQueue) Push ¶
func (pq *ListNodePriorityQueue) Push(x interface{})
func (ListNodePriorityQueue) Swap ¶
func (pq ListNodePriorityQueue) Swap(i, j int)
type StringHeap ¶
type StringHeap []string
A StringHeap is a min-heap of strings
func (StringHeap) Len ¶
func (h StringHeap) Len() int
func (StringHeap) Less ¶
func (h StringHeap) Less(i, j int) bool
func (*StringHeap) Pop ¶
func (h *StringHeap) Pop() interface{}
func (*StringHeap) Push ¶
func (h *StringHeap) Push(x interface{})
func (StringHeap) Swap ¶
func (h StringHeap) Swap(i, j int)
type TernarySearchTrie ¶
type TernarySearchTrie struct {
Root *TSTNode
}
func NewTST ¶
func NewTST() *TernarySearchTrie
func (*TernarySearchTrie) Contains ¶
func (t *TernarySearchTrie) Contains(key string) bool
func (*TernarySearchTrie) Get ¶
func (t *TernarySearchTrie) Get(key string) interface{}
func (*TernarySearchTrie) LongestPrefixOf ¶
func (t *TernarySearchTrie) LongestPrefixOf(query string) string
func (*TernarySearchTrie) Put ¶
func (t *TernarySearchTrie) Put(key string, val interface{})
func (*TernarySearchTrie) WithPrefix ¶
func (t *TernarySearchTrie) WithPrefix(query string) []interface{}
type TuplePriorityQueue ¶
type TuplePriorityQueue [][3]int
func (TuplePriorityQueue) Len ¶
func (pq TuplePriorityQueue) Len() int
func (TuplePriorityQueue) Less ¶
func (pq TuplePriorityQueue) Less(i, j int) bool
func (*TuplePriorityQueue) Pop ¶
func (pq *TuplePriorityQueue) Pop() interface{}
func (*TuplePriorityQueue) Push ¶
func (pq *TuplePriorityQueue) Push(x interface{})
func (TuplePriorityQueue) Swap ¶
func (pq TuplePriorityQueue) Swap(i, j int)
func (TuplePriorityQueue) Top ¶
func (pq TuplePriorityQueue) Top() [3]int