Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/EndlessCheng/codeforces-go
/ functions
Functions
8,098 in github.com/EndlessCheng/codeforces-go
⨍
Functions
8,098
◇
Types & classes
911
Function
countSwap
输入两个无重复元素的序列,返回通过交换相邻元素,从 a 到 b 所需的最小交换次数 保证 a b 包含相同的元素
copypasta/misc.go:483
Function
countTriples
(n int)
leetcode/biweekly/56/a/a.go:14
Function
countTriplets
(a []int, A, B int)
misc/nowcoder/10325/a/a.go:6
Function
countTriplets
(a []int)
leetcode/weekly/121/d/d.go:3
Function
countTriplets
(a []int)
leetcode/weekly/188/b/b.go:3
Function
countValidSubstring
输入一个仅包含 () 的括号串,返回右括号个数不少于左括号个数的非空子串个数
copypasta/misc.go:500
Function
countValidWords
Go 模拟,附详细注释 github.com/EndlessCheng/codeforces-go
leetcode/weekly/264/a/a.go:11
Function
countVowelStrings
github.com/EndlessCheng/codeforces-go
leetcode/weekly/213/b/b.go:6
Function
countVowelSubstrings
双指针 O(n) github.com/EndlessCheng/codeforces-go
leetcode/weekly/266/a/a.go:8
Function
countVowels
* 单独计算每个元音的出现次数 遍历 $\textit{word}$,若 $\textit{word}[i]$ 是元音,我们考察它能出现在多少个子字符串中。 设 $\textit{word}$ 的长度为 $n$。子字符串 $\textit{word}[l..r]$ 若要包含 $\textit{w
leetcode/weekly/266/b/b.go:22
Function
countWords
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/66/a/a.go:4
Function
cowModCount
(N int64)
misc/nowcoder/9005/c/c.go:6
Function
createSortedArray
(a []int)
leetcode/weekly/214/d/d.go:26
Function
createTargetArray
(nums []int, index []int)
leetcode/weekly/181/a/a.go:3
Function
daysBetweenDates
(date1 string, date2 string)
leetcode/weekly/177/a/a.go:8
Function
decimalToFraction
小数转分数 decimal like "2.15(376)", which means "2.15376376376..." https://zh.wikipedia.org/wiki/%E5%BE%AA%E7%8E%AF%E5%B0%8F%E6%95%B0#%E5%8C%96%E7%82%BA%E
copypasta/misc.go:608
Function
decode
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/44/c/c.go:4
Function
decode
github.com/EndlessCheng/codeforces-go
leetcode/weekly/223/a/a.go:4
Function
decodeCiphertext
github.com/EndlessCheng/codeforces-go
leetcode/weekly/267/c/c.go:6
Function
decompressRLElist
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/17/a/a.go:4
Function
decrypt
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/39/a/a.go:4
Function
deepestLeavesSum
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/16/c/c.go:6
Method
del
LC1938/周赛250D https://leetcode-cn.com/problems/maximum-genetic-difference-query/
copypasta/trie01.go:59
Method
delete
(key int)
main/500-599/555C.go:86
Method
delete
(key int)
main/800-899/840D.go:74
Method
delete
(key int)
main/gym/101628K.go:83
Method
delete
(key int)
copypasta/scapegoat_tree.go:128
Method
delete
(key rbKeyType)
copypasta/red_black_tree.go:204
Method
delete
删除字符串 s,返回字符串末尾对应的节点 LC1804 https://leetcode-cn.com/problems/implement-trie-ii-prefix-tree/
copypasta/trie.go:84
Method
delete
(key spKeyType)
copypasta/splay.go:169
Method
delete
(key int)
leetcode/weekly/196/d/d.go:91
Function
deleteDuplicateFolder
(paths [][]string)
leetcode/weekly/251/d/d.go:29
Function
deleteMiddle
* 快慢指针 这题其实就是把 [876. 链表的中间结点](https://leetcode-cn.com/problems/middle-of-the-linked-list/) 和删除链表结点结合起来 我们只需要在 876 题的基础上,额外记录 $\textit{slow}$ 结点的上一个结
leetcode/weekly/270/b/b.go:14
Function
deleteTreeNodes
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/14/c/c.go:4
Method
depthSize
两个基本信息:节点深度和子树大小 节点深度: - 深度与祖先:v 是 w 的祖先,当且仅当 dep[v]+dist(v,w)=dep[w] - 与 DFS 序结合,可以表达子树在某个深度上的一段信息(见 tree.inOutTimestamp) - 直径 中心(见 tree.diameter) 子树
copypasta/graph_tree.go:64
Function
destCity
(paths [][]string)
leetcode/weekly/187/a/a.go:3
Method
det
(b vecF)
misc/atcoder/abc168/c/c.go:16
Method
det
(vecF)
copypasta/geometry.go:1105
Function
detectCycle
LC 142
leetcode/main.go:757
Method
determinant
EXTRA: 求行列式(对结果模 mod) https://en.wikipedia.org/wiki/Determinant 参考 https://www.luogu.com.cn/blog/Stormy-Rey/calculate-det
copypasta/math_matrix.go:309
Method
dfs
EXTRA: 先染色,再递归 https://codeforces.com/problemset/problem/1470/D 无向图后向边定向 https://codeforces.com/problemset/problem/1519/E
copypasta/graph.go:149
Function
diagonalSort
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/18/c/c.go:6
Function
diagonalSum
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/34/a/a.go:4
Method
diameter
树的直径/最长链(DP 求法另见 dp.go 中的 diameter) 返回树的某条直径的两端点以及直径长度(最长链长度) 树的中心:树的直径的中点。直径长度为偶数时有一个,为奇数时有两个 如果给每条边加一个中点,那么可以保证树的中心为一个 性质: 直径的中点到所有叶子的距离和最小 对于两棵树,记第
copypasta/graph_tree.go:249
Function
dietPlanPerformance
github.com/EndlessCheng/codeforces-go
leetcode/weekly/152/b/b.go:4
Method
differenceInTree
LCA 应用:树上差分 操作为更新 v-w 路径上的点权或边权(初始为 0) 点权时 diff[lca] -= val 边权时 diff[lca] -= 2 * val(定义 diff 为点到父亲的差分值) https://www.luogu.com.cn/blog/RPdreamer/ci-fen
copypasta/graph_tree.go:973
Function
digSum
github.com/EndlessCheng/codeforces-go
misc/nowcoder/6384/c/c.go:6
Function
digitsCount
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/1/d/d.go:6
Method
dis
(vecF)
copypasta/geometry.go:1108
Method
dis2
(b vecF)
misc/atcoder/abc168/c/c.go:18
Method
dis2
(vecF)
copypasta/geometry.go:1109
Method
disToLine
点 a 到直线 l 的距离 若不取绝对值得到的是有向距离
copypasta/geometry.go:335
Method
disToSeg
点 a 到线段 l 的距离
copypasta/geometry.go:341
Function
displayTable
(orders [][]string)
leetcode/weekly/185/b/b.go:8
Function
distanceLimitedPathsExist
(n int, es, qs [][]int)
leetcode/weekly/220/d/d.go:29
Function
distinctEchoSubstrings
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/17/d/d.go:4
Function
distributeCandies
github.com/EndlessCheng/codeforces-go
leetcode/weekly/143/a/a.go:4
Method
div
(b Int)
copypasta/big.go:23
Method
div
(b rat)
copypasta/big.go:43
Function
div2
(a int)
copypasta/math_fwt.go:99
Method
divmod
(b poly)
copypasta/math_ntt.go:336
Method
divs
(b Int)
copypasta/big.go:14
Method
divs
(b rat)
copypasta/big.go:35
Method
divs
(k float64)
copypasta/geometry.go:194
Function
doll
github.com/EndlessCheng/codeforces-go
misc/nowcoder/9476/a/a.go:10
Function
domino
(n int, m int, broken [][]int)
leetcode/season/2019fall/d/d.go:3
Method
dot
(b vecF)
misc/atcoder/abc168/c/c.go:15
Method
dot
(vecF)
copypasta/geometry.go:1104
Function
dpCollections
* 动态规划 首先请透彻理解何为问题的「状态空间」,见 search.go 开头的注释 思考过程: 1.1 如何把问题形式化为状态空间?(可以从边界、子集的角度思考) 1.2 子问题是如何重叠的? 1.3 子问题是怎么逐层递进的?(题目描述、隐含的顺序) 2.1 如何定义状态?需要用几个维度表示
copypasta/dp.go:137
Method
dsu
树上启发式合并 DSU on tree / small to large https://oi-wiki.org/graph/dsu-on-tree/ NOTE: 合并的时候最好先循环计算一遍答案,再循环合并一遍,这样的习惯可避免产生把合并之后的数值算入答案中的 bug 讲解+套题 https://
copypasta/graph_tree.go:1301
Function
dynamicConnectivity
动态图连通性·离线(求 CC 个数或判断 v 和 w 是否连通) https://en.wikipedia.org/wiki/Dynamic_connectivity https://codeforces.com/gym/100551/problem/A https://codeforces.com
copypasta/union_find.go:381
Function
dynamicMedians
对顶堆求动态中位数:medians[i] = a[:i+1] 的中位数 https://www.luogu.com.cn/problem/P1168 LC295 https://leetcode-cn.com/problems/find-median-from-data-stream/ 与树状数组结
copypasta/heap.go:97
Function
earliestAcq
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/3/c/c.go:6
Function
earliestAndLatest
github.com/EndlessCheng/codeforces-go
leetcode/weekly/245/d/d.go:4
Function
eatenApples
(apples, days []int)
leetcode/weekly/221/b/b.go:17
Function
eliminateMaximum
github.com/EndlessCheng/codeforces-go
leetcode/weekly/248/b/b.go:6
Method
empty
()
main/1500-1599/1526C2.go:17
Method
empty
()
copypasta/bst.go:81
Function
encode
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/13/a/a.go:6
Function
entityParser
(s string)
leetcode/weekly/184/c/c.go:8
Method
equals
(b vecF)
copypasta/geometry.go:189
Function
eraseOverlapIntervals
LC 435
leetcode/main.go:1276
Method
eulerianPathOnDirectedGraph
(n, m int)
copypasta/graph.go:592
Method
eulerianPathOnUndirectedGraph
欧拉图(欧拉回路) 半欧拉图(欧拉路径) 半欧拉图:具有欧拉路径而无欧拉回路的图 判别法如下 https://oi-wiki.org/graph/euler/#_3 无向图-欧拉回路:连通且没有奇度数点 无向图-欧拉路径:连通且恰有 0 或 2 个奇度数点(若有则选择其中一奇度数点为起点) 有向
copypasta/graph.go:530
Function
evaluate
github.com/EndlessCheng/codeforces-go
leetcode/weekly/234/c/c.go:4
Function
executeInstructions
(n int, startPos []int, s string)
leetcode/weekly/273/b/b.go:6
Function
exist
LC 79
leetcode/main.go:396
Function
expand
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/2/c/c.go:6
Function
expectNumber
(a []int)
leetcode/season/2020spring2/a/a.go:3
Function
fastIO
快读,适用于输入量巨大的题目 相比 fmt.Fscan,每读入 1e6 个 int 可以加速约 400~450ms(Codeforces/AtCoder)
copypasta/io.go:36
Function
fasterIO
超快读 以 CF1276B(1e6 数据量)为例,测试结果如下: bufferIO 670 ms fastIO 296 ms fasterIO 202 ms fasterIO 202 ms (use syscall.Read(syscall.Stdin, buf)) 选择 4KB 作为缓
copypasta/io.go:118
Function
fenwickTree
* 树状数组(Fenwick Tree),二叉索引树(Binary Index Tree, BIT) https://en.wikipedia.org/wiki/Fenwick_tree 树状数组的基本用途是维护序列的前缀和 tree[i] = a[i-lowbit(i)+1] + ... + a[
copypasta/fenwick_tree.go:39
Function
filterRestaurants
(restaurants [][]int, veganFriendly int, maxPrice int, maxDistance int)
leetcode/weekly/173/b/b.go:5
Function
finalPrices
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/28/a/a.go:4
Function
finalValueAfterOperations
github.com/EndlessCheng/codeforces-go
leetcode/weekly/259/a/a.go:4
Method
find
查找字符串 s
copypasta/trie.go:66
Method
find
(key int)
copypasta/bst.go:83
Function
findAllPeople
* 按照相同时间分组 + 建图 DFS 首先将 $\textit{meetings}$ 按照时间 $\textit{time}$ 排序,然后遍历 $\textit{meetings}$,将时间相同的会议分成一组。 对于每组会议,由于专家可以互相共享秘密,我们可以将这些专家看成图上的点,专家 $\
leetcode/weekly/269/d/d.go:20
Function
findAllRecipes
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/68/b/b.go:4
Function
findBall
github.com/EndlessCheng/codeforces-go
leetcode/weekly/221/c/c.go:4
← previous
next →
6,601–6,700 of 8,098, ranked by callers