C

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UINT_MIN uint32 = 0               // 无符号整型最小值
	UINT_MAX uint32 = ^uint32(0)      // 无符号整型最大值
	INT_MAX         = ^uint32(0) >> 1 // 有符号整型最大值
	INT_MIX         = ^INT_MAX        // 有符号整型最小值 参考: https://blog.csdn.net/lishanleilixin/article/details/103269904

)
View Source
const (
	// 技巧类
	TwoPoint  = "TwoPoint"  // 双指针
	Bisection = "Bisection" // 二分法

	PreSum    = "PreSum"    // 前缀和
	DiffArray = "DiffArray" // 差分数组
	GapMulti  = "GapMulti"  // 间隔乘

	Xor        = "Xor"        // 异或
	Bit        = "Bit"        // 位运算
	UnionFind  = "UnionFind"  // 并查集
	PigeonCage = "PigeonCage" // 鸽笼原理

	Cache = "Cache"

	// 综合类 - 可以使用到多种方式解决
	SlidingWindow = "SlidingWindow"
	ReturnKMin    = "ReturnKMin"

	// 数学类
	Matrix    = "Matrix"
	Graphical = "Graphical" // 图形计算

	// 复杂边界类
	Calculator   = "Calculator"
	BigNumOpera  = "BigNumOpera"  // 大数操作(加、减、乘、除、合并)
	DigitalTrans = "DigitalTrans" // 人民币大小写转换
	RedBlackTree = "RedBlackTree"
)

技巧类 - 数据结构 - 算法 - 综合类 - 数学类 - 复杂边界类

View Source
const (
	Sort            = "Sort"
	Heap            = "Heap"
	Stack           = "Stack"
	EffectBrackets  = "EffectBrackets"  // 判断有效括号
	MonotonousStack = "MonotonousStack" // 单调栈
	MinStack        = "MinStack"        // 最小栈
	Queue           = "Queue"
	List            = "List"
	StringCompare   = "StringCompare" // 字符串对比算法

	// 树、图、回溯专区
	Recursion = "Recursion"
	Tree      = "Tree"
	PreOrder  = "PreOrder"  // 先序遍历
	PostOrder = "PostOrder" // 后续遍历
	InOrder   = "InOrder"   // 中序遍历
	Graph     = "Graph"
)

数据结构专题

View Source
const (
	Dynamic = "Dynamic" // 动态规划
	LIS     = "LIS"     // 最长递增子序列  Longest Increasing SubSequence
	LCS     = "LCS"     // 最长公共子序列  Longest Common     Sequence
	LNS     = "LNS"     // 最长无重复子串  Longest NonRepeat  SubSequence
	LMS     = "LMS"     // 最大子段乘积   Largest  MultiOf    SubSequence
	LMG     = "LMG"     // 最大间隔乘积   Largest  MultiOf    Gap
	LSG     = "LSG"     // 最大间隔和     Largest  SumOf      Gap
	LSS     = "LSS"     // 最大子段和     Largest  SumOf      SubSequence

	Greedy = "Greedy" // 贪心算法

	BackTrack         = "BackTrack"       // 回溯(递归、剪枝)
	OptimalSchedule   = "OptimalSchedule" // 调度
	Permutation       = "Permutation"     // 排列
	Combination       = "Combination"     //组合
	PermuteAndCombine = "PermuteAndCombine"
)

算法专题

Variables

View Source
var (
	ErrorNum   = -9999
	ErrorFloat = -9999.0
)

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Tags []string `json:"tags"`
	Desc *Desc    `json:"desc"`
}

*

  • @author ljfirst
  • @version V1.0
  • @date 2023/7/10 00:52
  • @author-Email ljfirst@mail.ustc.edu.cn
  • @blogURL https://blog.csdn.net/ljfirst
  • @description *

func (*Attribute) GetDesc

func (m *Attribute) GetDesc() *Desc

type Change

type Change func(interface{}, int, int)

func ArrayChange

func ArrayChange() Change

type Compare

type Compare func(interface{}, interface{}) bool

func ArrayCompare

func ArrayCompare() Compare

type Desc

type Desc struct {
	Name        string            `json:"name"        common:"名称"`
	NameCn      string            `json:"name_cn"     common:"中文名称"`
	Description string            `json:"description" common:"题目描述"`
	Tips        string            `json:"tips"        common:"解题思想"`
	ParamsDesc  map[string]string `json:"params_desc" common:"参数描述,输入输出描述"`
	Example     map[int]string    `json:"example"     common:"出入参示例"`
}

type GT

type GT func(interface{}, int, int) bool

*

  • @author ljfirst
  • @version V1.0
  • @date 2023/7/5 19:43
  • @author-Email ljfirst@mail.ustc.edu.cn
  • @blogURL https://blog.csdn.net/ljfirst
  • @description *
var ArrayGT GT = func(arrayV interface{}, index1 int, index2 int) bool {
	value := reflect.ValueOf(arrayV)
	if value.Kind() != reflect.Array && value.Kind() != reflect.Slice {
		return false
	}
	if value.Len() <= index1 || value.Len() <= index2 {
		return false
	}
	array, ok := arrayV.([]int)
	if !ok {
		array1, ok1 := arrayV.([]interface{})
		if !ok1 {
			return false
		}
		return array1[index1].(int) > array1[index2].(int)
	}
	return array[index1] > array[index2]
}

type Option

type Option struct {
	IsSmallHeap bool // 是否小顶堆
	LimitSize   int  // 限制容量-不可以扩容
	MaxSize     int  // 最大容量-可以扩容

	FromHighToLow bool // true表示从高到低排序,默认 false 表示从低到高排序
	HeadInsert    bool // 头插法,默认false是尾插法

	GT      GT
	Change  Change
	Compare Compare
}

func NewOptions

func NewOptions(options ...Options) *Option

type Options

type Options func(*Option)

*

  • @author ljfirst
  • @version V1.0
  • @date 2023/7/4 21:23
  • @author-Email ljfirst@mail.ustc.edu.cn
  • @blogURL https://blog.csdn.net/ljfirst
  • @description 优先队列 Option *

func WithChange

func WithChange(change Change) Options

func WithCompare

func WithCompare(compare Compare) Options

func WithFromHighToLow

func WithFromHighToLow(fromHighToLow bool) Options

func WithGT

func WithGT(gt GT) Options

func WithHeadInsert

func WithHeadInsert(headInsert bool) Options

func WithLimitSize

func WithLimitSize(limitSize int) Options

func WithMaxSize

func WithMaxSize(maxSize int) Options

func WithQueueType

func WithQueueType(smallHeap bool) Options

Jump to

Keyboard shortcuts

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