exercise

package
v0.0.0-...-22d4dea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SIGNROOM = 0x7fffffff
	SIGNGATE = 0
	SIGNWALL = 0xffffffff
)
View Source
const (
	URL       = "https://do.mcquay.us/ssh/short.txt"
	FAILUREKW = "Failed password"
)
View Source
const EMPST = ""

Variables

This section is empty.

Functions

func BTLCS

func BTLCS(r *bstNode) uint

func BTVertOrder

func BTVertOrder(r *bstNode) [][]uint16

func CWMoreWatter

func CWMoreWatter(ls []uint) uint

Container With Most Water

func CombSum

func CombSum(n []uint, t uint) uint

Combination Sum

func CombinationSum

func CombinationSum(nums []int, s int) ([][]int, bool)

func KClosest

func KClosest(e []int, t, k int) []int

Find K Closest Elements

func KFreqWords

func KFreqWords(wds []string, k int) []string

K Frequent Words

func MagicHash

func MagicHash(key string, size int) int

func MaxAvgSubarr

func MaxAvgSubarr(ns []int, l int) (int, int)

Maximum Average Subarray II

func MaxI2

func MaxI2(a, b int) int

func MaxI3

func MaxI3(a, b, c int) int

func MergeTwo

func MergeTwo(arr1 []int, arr2 []int) []int

func MinI3

func MinI3(a, b, c int) int

func MinSubarrSum

func MinSubarrSum(nums []int, t int) (int, bool)

Minimum Size Subarray Sum

func MissNumber

func MissNumber(s []byte, r uint) (uint, uint, bool)

Find the Missing Number, r < 30

func PartSubset

func PartSubset(ns []uint) bool

Partition Equal Subset Sum

func ReverseWords

func ReverseWords(ws string) string

func TopKFreWords

func TopKFreWords(wds []string, k int) ([]string, error)

Types

type BinaryMatrix

type BinaryMatrix struct {
	Get        func(int, int) int
	Dimensions func() []int
}

type Concordance

type Concordance struct {
	// contains filtered or unexported fields
}

type EDpoints

type EDpoints [][]int

func (EDpoints) Len

func (h EDpoints) Len() int

func (EDpoints) Less

func (h EDpoints) Less(i, j int) bool

func (EDpoints) Peek

func (h EDpoints) Peek() interface{}

func (*EDpoints) Pop

func (h *EDpoints) Pop() interface{}

func (*EDpoints) Push

func (h *EDpoints) Push(x interface{})

func (EDpoints) Swap

func (h EDpoints) Swap(i, j int)

type Employee

type Employee struct {
	Id           int
	Importance   int
	Subordinates []int
}

* 690. Employee Importance

type FirstUnique

type FirstUnique struct {
	// contains filtered or unexported fields
}

func FUConstructor

func FUConstructor(nums []int) FirstUnique

func (*FirstUnique) Add

func (fu *FirstUnique) Add(n int)

func (*FirstUnique) ShowFirstUnique

func (fu *FirstUnique) ShowFirstUnique() int

type Heap

type Heap struct {
	// contains filtered or unexported fields
}

type HitCounter

type HitCounter struct {
	// contains filtered or unexported fields
}

func HCConstructor

func HCConstructor() HitCounter

* Initialize your data structure here.

func (*HitCounter) GetHits

func (hc *HitCounter) GetHits(ts int) int
  • Return the number of hits in the past 5 minutes. @param timestamp - The current timestamp (in seconds granularity).

func (*HitCounter) Hit

func (hc *HitCounter) Hit(ts int)
  • Record a hit. @param timestamp - The current timestamp (in seconds granularity).

type IntHeap

type IntHeap []int

func (IntHeap) Len

func (h IntHeap) Len() int

func (IntHeap) Less

func (h IntHeap) Less(i, j int) bool

func (IntHeap) Swap

func (h IntHeap) Swap(i, j int)

type Interval

type Interval struct {
	Start, End int
}

* 759. Employee Free Time

type Iterator

type Iterator struct {
}

type K9board

type K9board struct {
	// contains filtered or unexported fields
}

func (*K9board) K9Path

func (b *K9board) K9Path() int

Knight Shortest Path

type LRUCache

type LRUCache struct {
	Cap  int
	Head *dLinkedNode
	Tail *dLinkedNode
	// contains filtered or unexported fields
}

LRU Cache

func (*LRUCache) Get

func (cache *LRUCache) Get(k int) (int, bool)

func (*LRUCache) Init

func (cache *LRUCache) Init(c int)

type ListNode

type ListNode struct {
	Val  int
	Next *ListNode
}

*

  • Definition for singly-linked list.
  • type ListNode struct {
  • Val int
  • Next *ListNode
  • }

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func LConstructor

func LConstructor() Logger

* Initialize your data structure here.

func (*Logger) ShouldPrintMessage

func (l *Logger) ShouldPrintMessage(ts int, m string) bool
  • Returns true if the message should be printed in the given timestamp, otherwise returns false. If this method returns false, the message will not be printed. The timestamp is in seconds granularity.

type MaxStack

type MaxStack struct {
	// contains filtered or unexported fields
}

func (*MaxStack) PeekMax

func (this *MaxStack) PeekMax() int

func (*MaxStack) Pop

func (this *MaxStack) Pop() int

func (*MaxStack) PopMax

func (this *MaxStack) PopMax() int

func (*MaxStack) Push

func (this *MaxStack) Push(x int)

func (*MaxStack) Top

func (this *MaxStack) Top() int

type MinStack

type MinStack struct {
	// contains filtered or unexported fields
}

* 155. Min Stack

func MSConstructor

func MSConstructor() MinStack

* initialize your data structure here.

func (*MinStack) GetMin

func (this *MinStack) GetMin() int

func (*MinStack) Pop

func (this *MinStack) Pop()

func (*MinStack) Push

func (this *MinStack) Push(val int)

func (*MinStack) Top

func (this *MinStack) Top() int

type MyCalendar

type MyCalendar struct {
	// contains filtered or unexported fields
}

func MyCalendarConstructor

func MyCalendarConstructor() MyCalendar

func (*MyCalendar) Book

func (c *MyCalendar) Book(s, e int) bool

type Node

type Node struct {
	Val       int
	Neighbors []*Node
}

type NumMatrix

type NumMatrix struct {
	// contains filtered or unexported fields
}

func NumMatrixConstructor

func NumMatrixConstructor(matrix [][]int) NumMatrix

func (*NumMatrix) SumRegion

func (this *NumMatrix) SumRegion(row1 int, col1 int, row2 int, col2 int) int

type PeekingIterator

type PeekingIterator struct {
	// contains filtered or unexported fields
}

func PeekingIteratorConstructor

func PeekingIteratorConstructor(iter *Iterator) *PeekingIterator

type PreNode

type PreNode struct {
	// contains filtered or unexported fields
}

type RDNode

type RDNode struct {
	Val    int
	Next   *RDNode
	Random *RDNode
}

type RLEIterator

type RLEIterator struct {
	// contains filtered or unexported fields
}

func RLEConstructor

func RLEConstructor(A []int) RLEIterator

func (*RLEIterator) Next

func (it *RLEIterator) Next(n int) int

type RandomizedSet

type RandomizedSet struct {
	// contains filtered or unexported fields
}

func RSConstructor

func RSConstructor() RandomizedSet

* Initialize your data structure here.

func (*RandomizedSet) GetRandom

func (rs *RandomizedSet) GetRandom() int

* Get a random element from the set.

func (*RandomizedSet) Insert

func (rs *RandomizedSet) Insert(val int) bool

* Inserts a value to the set. Returns true if the set did not already contain the specified element.

func (*RandomizedSet) Remove

func (rs *RandomizedSet) Remove(val int) bool

* Removes a value from the set. Returns true if the set contained the specified element.

type SCNode

type SCNode struct {
	Val  int
	Next *SCNode
}

type SnapshotArray

type SnapshotArray struct {
	// contains filtered or unexported fields
}

func SAConstructor

func SAConstructor(l int) SnapshotArray

func (*SnapshotArray) Get

func (sa *SnapshotArray) Get(index int, id int) int

func (*SnapshotArray) Set

func (sa *SnapshotArray) Set(index int, val int)

func (*SnapshotArray) Snap

func (sa *SnapshotArray) Snap() int

type Solution

type Solution struct {
	// contains filtered or unexported fields
}

func RPIConstructor

func RPIConstructor(nums []int) Solution

func (*Solution) Pick

func (this *Solution) Pick(target int) int

type SparseVector

type SparseVector struct {
	// contains filtered or unexported fields
}

* 1570. Dot Product of Two Sparse Vectors

*

  • Your SparseVector object will be instantiated and called as such:
  • v1 := Constructor(nums1);
  • v2 := Constructor(nums2);
  • ans := v1.dotProduct(v2);

func SVConstructor

func SVConstructor(nums []int) SparseVector

type TimeMap

type TimeMap struct {
	// contains filtered or unexported fields
}

func Constructor

func Constructor() TimeMap

* Initialize your data structure here.

func TMConstructor

func TMConstructor() TimeMap

* Initialize your data structure here.

func (*TimeMap) Get

func (tm *TimeMap) Get(key string, timestamp int) string

func (*TimeMap) Get1

func (this *TimeMap) Get1(key string, timestamp int) string

func (*TimeMap) Set

func (tm *TimeMap) Set(key string, value string, timestamp int)

func (*TimeMap) Set1

func (this *TimeMap) Set1(key string, value string, timestamp int)

type TreeNode

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

type WCHeap

type WCHeap []*Wdc

func (WCHeap) Len

func (h WCHeap) Len() int

func (WCHeap) Less

func (h WCHeap) Less(i, j int) bool

func (*WCHeap) Pop

func (h *WCHeap) Pop() interface{}

func (*WCHeap) Push

func (h *WCHeap) Push(x interface{})

func (WCHeap) Swap

func (h WCHeap) Swap(i, j int)

type Wdc

type Wdc struct {
	// contains filtered or unexported fields
}

type WordBreak

type WordBreak struct {
	// contains filtered or unexported fields
}

func (*WordBreak) CanWordBreak

func (wb *WordBreak) CanWordBreak(t string) bool

type WordDictionary

type WordDictionary struct {
	// contains filtered or unexported fields
}

* Need a flag in the tree node of if the word ends here

func WDConstructor

func WDConstructor() WordDictionary

func (*WordDictionary) AddWord

func (t *WordDictionary) AddWord(word string)

func (*WordDictionary) Search

func (t *WordDictionary) Search(word string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL