alg

package
v0.0.0-...-6215f49 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CrossPrint

func CrossPrint()

启动两个协程交替输出字母和数字

func Find

func Find(slice []int, target int, workCount int) (int, bool)

使用协程查找数组里面某个元素

func FindMaxn

func FindMaxn(s []int, n int) int

找到一个随机数组中,第n大的数

func HeapSort

func HeapSort(nums []int)

堆排序

func InOrderTraversal

func InOrderTraversal(p *TreeNode, res *[]int)

func MergeSort

func MergeSort(nums []int) []int

分治排序

func PostOrderTraversal

func PostOrderTraversal(p *TreeNode, res *[]int)

func PreOrderTraversal

func PreOrderTraversal(p *TreeNode, res *[]int)

func QuickSort

func QuickSort(s []int)

快速排序

func Search(slice []int, target int) bool

使用协程查找数组里面某个元素

func Search2

func Search2(slice []int, target int) (bool, error)

Types

type LRUCache

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

LRU算法,选择最近最久未使用的页面予以淘汰。

func Constructor

func Constructor(capacity int) LRUCache

func (*LRUCache) Get

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

func (*LRUCache) Put

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

type ListNode

type ListNode struct {
	Next *ListNode
	// contains filtered or unexported fields
}

func ReverseList

func ReverseList(head *ListNode) *ListNode

func ReverseSeg

func ReverseSeg(head *ListNode, c int) (result *ListNode)

根据指定常数反转链表,比如1->2->3->4->5->6 指定2,输出:2->1->4->3->6->5 指定3,输出:3->2->1->6->5->4

func (*ListNode) String

func (list *ListNode) String()

type Pair

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

type TreeNode

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

Jump to

Keyboard shortcuts

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