winymu / arts Goto Github PK
View Code? Open in Web Editor NEWEvery Week ARTS
Every Week ARTS
算法,主要是以下几种:
基础技巧:分治、二分、贪心
排序算法:快速排序、归并排序、计数排序
搜索算法:回溯、递归、深度优先遍历,广度优先遍历,二叉搜索树等
图论:最短路径、最小生成树
动态规划:背包问题、最长子序列
数据结构,主要有如下几种:
数组与链表:单 / 双向链表
栈与队列
哈希表
堆:最大堆 / 最小堆
树与图:最近公共祖先、并查集
字符串:前缀树(字典树) / 后缀树
在公司内部引入Go语言的三个步骤:
Go语言中的生成器、wait group和闭包
KMP算法核心:
"部分匹配值"就是"前缀"和"后缀"的最长的共有元素的长度。以"ABCDABD"为例,
- "A"的前缀和后缀都为空集,共有元素的长度为0;
- "AB"的前缀为[A],后缀为[B],共有元素的长度为0;
- "ABC"的前缀为[A, AB],后缀为[BC, C],共有元素的长度0;
- "ABCD"的前缀为[A, AB, ABC],后缀为[BCD, CD, D],共有元素的长度为0;
- "ABCDA"的前缀为[A, AB, ABC, ABCD],后缀为[BCDA, CDA, DA, A],共有元素为"A",长度为1;
- "ABCDAB"的前缀为[A, AB, ABC, ABCD, ABCDA],后缀为[BCDAB, CDAB, DAB, AB, B],共有元素为"AB",长度为2;
- "ABCDABD"的前缀为[A, AB, ABC, ABCD, ABCDA, ABCDAB],后缀为[BCDABD, CDABD, DABD, ABD, BD, D],共有元素的长度为0。
func TestKmpNext(t *testing.T) {
str := `agctagcagctagctg`
// str := `aaaaaaaa`
L := len(str)
next := make([]int, L)
for i := 1; i < L; i++ {
// 首先检查当前元素i的 next[i] 的值
// 如果为0表示前面的字符串中就没有“前缀” == “后缀”
if next[i-1] == 0 {
// 从头开始,检查与第一个字符是否相等,相等则有一个匹配
if str[i] == str[0] {
next[i] = 1
}
} else { // 前面的字符串中就出现了“前缀” == “后缀”, 则next[i-1] !=0
if str[i] == str[next[i-1]] {
next[i] = next[i-1] + 1
} else if str[i] == str[0] {
next[i] = 1
}
}
}
fmt.Println("next:", next)
}
innodb引擎自增主键非连续的原因:
Mysql的Join过程及优化
重温OAuth2.0
http://www.ruanyifeng.com/blog/2019/04/oauth-grant-types.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.