golang

package module
v0.0.0-...-40d646d Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2020 License: MIT Imports: 10 Imported by: 0

README

leetcode

FOSSA Status

Build Status

My Codes for LeetCode platform

This is the repository for my Leetcode solutions and their corresponding tests

License

FOSSA Status

Documentation

Index

Constants

View Source
const (
	Unexplored state = iota
	Pending
	Explored
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BSTIterator

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

@lc code=start *

  • Definition for a binary tree node.
  • type TreeNode struct {
  • Val int
  • Left *TreeNode
  • Right *TreeNode
  • }

func (*BSTIterator) HasNext

func (this *BSTIterator) HasNext() bool

* @return whether we have a next smallest number

func (*BSTIterator) Next

func (this *BSTIterator) Next() int

* @return the next smallest number

type ByHeightAndRank

type ByHeightAndRank [][]int

func (ByHeightAndRank) Len

func (b ByHeightAndRank) Len() int

func (ByHeightAndRank) Less

func (b ByHeightAndRank) Less(i, j int) bool

func (ByHeightAndRank) Swap

func (b ByHeightAndRank) Swap(i, j int)

type IntHeap

type IntHeap []int

An IntHeap is a max-heap of ints.

func (IntHeap) Len

func (h IntHeap) Len() int

func (IntHeap) Less

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

Maxheap implementation

func (*IntHeap) Pop

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

Pop uses pointer receivers because they modify the slice's length,

func (*IntHeap) Push

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

Push uses pointer receivers because they modify the slice's length,

func (IntHeap) Swap

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

type LRUCache

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

LRUCache is a data structure for Problem 145

func (*LRUCache) Get

func (object *LRUCache) Get(key int) int

Get gets an object by key

func (*LRUCache) Put

func (object *LRUCache) Put(key int, value int)

Put creates an object with provided key and value

type ListNode

type ListNode struct {
	Val  int
	Next *ListNode
}

ListNode defines a singly-linked list.

type Node

type Node struct {
	Val   int
	Prev  *Node
	Next  *Node
	Child *Node
}

Definition for a Node.

type NumArray

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

@lc code=start

func NumArrayConstructor

func NumArrayConstructor(nums []int) NumArray

func (*NumArray) SumRange

func (this *NumArray) SumRange(i int, j int) int

type Operation

type Operation int

@lc code=start

const (
	Add Operation = iota
	Sub
	Mul
	Last
)

func (Operation) String

func (o Operation) String() string

type RandomizedCollection

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

@lc code=start

func ConstructorRandom

func ConstructorRandom() RandomizedCollection

* Initialize your data structure here.

func (*RandomizedCollection) GetRandom

func (this *RandomizedCollection) GetRandom() int

* Get a random element from the collection.

func (*RandomizedCollection) Insert

func (this *RandomizedCollection) Insert(val int) bool

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

func (*RandomizedCollection) Remove

func (this *RandomizedCollection) Remove(val int) bool

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

type RandomizedSet

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

@lc code=start

func (*RandomizedSet) GetRandom

func (this *RandomizedSet) GetRandom() int

* Get a random element from the set.

func (*RandomizedSet) Insert

func (this *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 (this *RandomizedSet) Remove(val int) bool

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

type Solution

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

@lc code=start

func SolConstructor

func SolConstructor(w []int) Solution

func (*Solution) PickIndex

func (this *Solution) PickIndex() int

type StockSpanner

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

@lc code=start

func StockConstructor

func StockConstructor() StockSpanner

func (*StockSpanner) Next

func (this *StockSpanner) Next(price int) int

type TreeNode

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

TreeNode is a data structure for BST

type Trie

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

@lc code=start

func TrieConstructor

func TrieConstructor() Trie

* Initialize your data structure here.

func (*Trie) Insert

func (this *Trie) Insert(word string)

* Inserts a word into the trie.

func (*Trie) Search

func (this *Trie) Search(word string) bool

* Returns if the word is in the trie.

func (*Trie) StartsWith

func (this *Trie) StartsWith(prefix string) bool

* Returns if there is any word in the trie that starts with the given prefix.

type UnionFind

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

UnionFind data type contains the root and size of object in UnionFind Data structure

func New

func New(size int) *UnionFind

New returns an initialized list of size

func (*UnionFind) Connected

func (uf *UnionFind) Connected(p int, q int) bool

Connected checks if items p,q are connected

func (*UnionFind) Find

func (uf *UnionFind) Find(p int) int

Find gets the root of the given key

func (*UnionFind) Root

func (uf *UnionFind) Root(p int) int

Root or Find traverses each parent element while compressing the levels to find the root element of p If we attempt to access an element outside the array it returns -1

func (*UnionFind) Union

func (uf *UnionFind) Union(p int, q int)

Union connects p and q by finding their roots and comparing their respective size arrays to keep the tree flat

Source Files

Directories

Path Synopsis
golang module

Jump to

Keyboard shortcuts

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