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
checkIfExist
(arr []int)
leetcode/weekly/175/a/a.go:3
Function
checkIfPangram
github.com/EndlessCheng/codeforces-go
leetcode/weekly/237/a/a.go:4
Function
checkIfPrerequisite
(n int, prerequisites [][]int, queries [][]int)
leetcode/biweekly/27/c/c.go:3
Function
checkOnesSegment
github.com/EndlessCheng/codeforces-go
leetcode/weekly/231/a/a.go:6
Function
checkOverlap
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/23/c/c.go:6
Function
checkPalindromeFormation
(a, b string)
leetcode/weekly/210/c/c.go:27
Function
checkPartitioning
github.com/EndlessCheng/codeforces-go
leetcode/weekly/226/d/d.go:4
Function
checkPowersOfThree
(n int)
leetcode/biweekly/47/b/b.go:11
Function
checkStraightLine
(ps [][]int)
leetcode/weekly/159/a/a.go:3
Function
checkZeroOnes
github.com/EndlessCheng/codeforces-go
leetcode/weekly/242/a/a.go:4
Function
cherryPickup
(g [][]int)
leetcode/biweekly/27/d/d.go:3
Function
circleGame
github.com/EndlessCheng/codeforces-go
leetcode/season/2021fall/d/d.go:6
Function
circularPermutation
(n int, start int)
leetcode/weekly/160/b/b.go:3
Function
circumcenterR
EXTRA: 外接圆半径 R 下面交换了一下乘除的顺序,减小精度的丢失 todo https://codeforces.com/problemset/problem/274/C
copypasta/geometry.go:274
Function
circumcenterR2
(a, b, c vecF)
copypasta/geometry.go:278
Function
city
github.com/EndlessCheng/codeforces-go
misc/nowcoder/10323/c/c.go:6
Function
closeStrings
github.com/EndlessCheng/codeforces-go
leetcode/weekly/215/b/b.go:6
Function
closedIsland
(grid [][]int)
leetcode/weekly/162/c/c.go:3
Function
closestCost
github.com/EndlessCheng/codeforces-go
leetcode/weekly/230/b/b.go:4
Function
closestDivisors
(num int)
leetcode/weekly/177/c/c.go:3
Function
closestRoom
(a, qs [][]int)
leetcode/biweekly/51/d/d.go:84
Function
closestToTarget
github.com/EndlessCheng/codeforces-go
leetcode/weekly/198/d/d.go:4
Method
cmp
(b Int)
copypasta/big.go:19
Method
cmp
(b rat)
copypasta/big.go:39
Function
collections
()
leetcode/weekly/163/main.go:8
Function
colorTheGrid
(m, n int)
leetcode/weekly/249/c/c.go:6
Function
combinationSum
LC 39
leetcode/main.go:152
Function
combinationSum2
LC 40
leetcode/main.go:175
Function
combinationSum3
LC 216
leetcode/main.go:942
Function
combinatoricsCollection
* 组合数学 https://en.wikipedia.org/wiki/Combination https://en.wikipedia.org/wiki/Enumerative_combinatorics https://en.wikipedia.org/wiki/Binomial_theore
copypasta/math.go:2916
Function
commonCollection
解决问题的一般方法 https://codeforces.com/blog/entry/92248?#comment-809401 General ideas https://codeforces.com/blog/entry/48417 从特殊到一般:尝试修改条件或缩小题目的数据范围,先研究某个特
copypasta/common.go:106
Function
concatenatedBinary
todo O(log n) ? github.com/EndlessCheng/codeforces-go
leetcode/weekly/218/c/c.go:8
Function
confusingNumberII
(n int)
leetcode/biweekly/2/d/d.go:29
Function
connect
LC 117, O(1) 空间复杂度
leetcode/main.go:529
Function
connectSticks
(sticks []int)
leetcode/biweekly/7/c/c.go:16
Function
connectTwoGroups
github.com/EndlessCheng/codeforces-go
leetcode/weekly/207/d/d.go:4
Function
constrainedSubsetSum
(a []int, k int)
leetcode/weekly/186/d/d.go:61
Function
construct2DArray
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/62/a/a.go:4
Function
constructor
()
leetcode/testutil/leetcode_test.go:95
Method
contain
bst 存的是互不相交的区间 [key,value),现查询是否包含区间 [l,r)
copypasta/bst.go:191
Function
containsCycle
(g [][]byte)
leetcode/biweekly/33/d/d.go:7
Function
containsPattern
github.com/EndlessCheng/codeforces-go
leetcode/weekly/204/a/a.go:4
Function
continuedFractionCollections
()
copypasta/math_continued_fraction.go:8
Function
convertBST
LC 538 1038 反序中序遍历
leetcode/main.go:1325
Function
copyMatrix
(a matrix)
copypasta/math_matrix.go:42
Function
cosineRule
余弦定理,输入两边及夹角,计算对边长度
copypasta/geometry.go:250
Function
cosineRuleVec
(va, vb vecF, angle float64)
copypasta/geometry.go:253
Function
countBalls
github.com/EndlessCheng/codeforces-go
leetcode/weekly/226/a/a.go:4
Function
countCharacters
(words []string, chars string)
leetcode/weekly/150/a/a.go:3
Function
countCombinations
(pieces []string, positions [][]int)
leetcode/biweekly/64/d/d.go:55
Function
countConsistentStrings
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/41/a/a.go:4
Method
countCycle3
todo 极大团计数 分团覆盖问题 Clique cover https://en.wikipedia.org/wiki/Clique_cover todo 图的同构 todo 树的同构 AHU 算法 https://oi-wiki.org/graph/tree-ahu/ todo hashing
copypasta/graph.go:3898
Method
countCycle4
四元环计数/判定 O(m√m) 同三元环那样定向,将四元环拆成左右各两条边,这两条边为一条无向边和一条有向边,然后统计无向+有向的对数 具体参见 https://blog.csdn.net/weixin_43466755/article/details/112985722 https://cdn.l
copypasta/graph.go:3939
Function
countDifferentSubsequenceGCDs
github.com/EndlessCheng/codeforces-go
leetcode/weekly/235/d/d.go:4
Function
countDigitOne
LC 233 小于等于 n 的非负整数中数字 1 出现的个数
leetcode/main.go:1006
Method
countDistinctSubstring
s 的本质不同子串数量 O(n^2) 做法是插入每个后缀,统计节点数。但题目往往会带上额外的条件 https://codeforces.com/problemset/problem/271/D 注:这题还可以用后缀数组+前缀和二分来做到 O(nlogn)
copypasta/trie.go:185
Function
countGoodNumbers
(n int64)
leetcode/weekly/248/c/c.go:6
Function
countGoodRectangles
github.com/EndlessCheng/codeforces-go
leetcode/weekly/224/a/a.go:4
Function
countGoodSubstrings
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/53/a/a.go:4
Function
countGoodTriplets
github.com/EndlessCheng/codeforces-go
leetcode/weekly/200/a/a.go:4
Function
countHighestScoreNodes
github.com/EndlessCheng/codeforces-go
leetcode/weekly/264/c/c.go:4
Function
countHomogenous
github.com/EndlessCheng/codeforces-go
leetcode/weekly/228/b/b.go:4
Function
countKDifference
O(n) 做法 github.com/EndlessCheng/codeforces-go
leetcode/biweekly/61/a/a.go:6
Function
countLargestGroup
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/23/a/a.go:4
Function
countLetters
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/8/a/a.go:4
Function
countLimitXOR
上面也可以用哈希表做
copypasta/trie01.go:151
Method
countLimitXOR
求与 v 异或值不超过 limit 的元素个数 核心原理是,当 limit+1 的某一位是 1 的时候,若该位异或值取 0,则后面的位是可以取任意数字的 如果在 limit 上而不是 limit+1 上讨论,就要处理当前异或为 1 的情况了,比较麻烦 LC1803/周赛233D https://le
copypasta/trie01.go:131
Function
countMatches
github.com/EndlessCheng/codeforces-go
leetcode/weekly/230/a/a.go:4
Function
countMaxOrSubsets
O(2^n) 子集或写法 github.com/EndlessCheng/codeforces-go
leetcode/weekly/263/c/c.go:6
Method
countMode
EXTRA: countDiff 区间不同元素个数 做法是维护左侧相同元素的位置 todo 参考 https://www.luogu.com.cn/problem/solution/SP3267 https://www.luogu.com.cn/problem/P1972 https://www.l
copypasta/segment_tree.go:671
Function
countNegatives
二分亦可。
leetcode/weekly/176/a/a.go:4
Function
countNodes
LC 222 完全二叉树节点个数 O(logn) 解法
leetcode/main.go:967
Function
countOdds
(low, high int)
leetcode/biweekly/31/a/a.go:3
Function
countOfAtoms
(s string)
leetcode/weekly/58/c/c.go:11
Function
countOrders
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/20/d/d.go:6
Function
countPairs
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/47/d/d.go:6
Function
countPairs
github.com/EndlessCheng/codeforces-go
leetcode/weekly/222/b/b.go:4
Function
countPairs
(nums []int, low, high int)
leetcode/weekly/233/d/d.go:28
Function
countPairs2
(a []int, low, high int)
leetcode/weekly/233/d/d.go:103
Function
countPalindromicSubsequence
* 枚举回文子序列的中间字符,并枚举其左右字符(从 $\texttt{a}$ 到 $\texttt{z}$),若该字符在中间字符左右侧均存在,则找到一个回文子序列 我们可以在枚举中间字符的同时,计算字符串的前缀和与后缀和,这样就能判断某个字符在中间字符左右侧均存在 由于题目要求相同的子序列只计数一次
leetcode/weekly/249/b/b.go:13
Function
countPaths
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/59/c/c.go:4
Function
countPoints
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/50/b/b.go:4
Function
countPoints
(s string)
leetcode/weekly/271/a/a.go:8
Method
countPrefixOfString
结合 rank 和 kth,可以求出一个字符串的前驱和后继 见 bst.go 中的 prev 和 next 返回字符串 s 在 trie 中的前缀个数 https://www.acwing.com/problem/content/144/ https://codeforces.com/gym/101
copypasta/trie.go:154
Function
countPyramids
* 动态规划 先求正金字塔。 定义 $\textit{dp}[i][j]$ 表示金字塔顶端位于 $(i,j)$ 时的最大层数($1$ 层也算)。如果顶端在 $(i,j)$ 的金字塔最大能有 $x$ 层,那么顶端在 $(i,j)$ 的金字塔也可以有 $x-1,x-2,\cdot,\1$ 层。由于要
leetcode/biweekly/66/d/d.go:22
Function
countQuadruplets
github.com/EndlessCheng/codeforces-go
leetcode/weekly/257/a/a.go:4
Method
countRange
EXTRA: 查询区间 [l,r] 中在 [low,high] 范围内的元素个数 low 和 high 为离散化后的值(从 1 开始) http://acm.hdu.edu.cn/showproblem.php?pid=4417 https://codeforces.com/problemset/p
copypasta/segment_tree.go:643
Function
countRangeSum
LC 327 基于求逆序对的思路
leetcode/main.go:1136
Function
countRestrictedPaths
(n int, edges [][]int)
leetcode/weekly/231/c/c.go:44
Method
countRoots
st 所处连通分量的大小
copypasta/union_find.go:283
Function
countRoutes
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/34/d/d.go:4
Function
countServers
(grid [][]int)
leetcode/weekly/164/b/b.go:3
Function
countSpecialSubsequences
(nums []int)
leetcode/weekly/252/d/d.go:22
Function
countSquares
(mat [][]int)
leetcode/weekly/165/c/c.go:3
Function
countSteppingNumbers
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/10/c/c.go:9
Method
countStringHasPrefix
返回 trie 中前缀为 p 的字符串个数 此时 o.cnt 保存子树字符串个数 https://codeforces.com/gym/101628/problem/K LC1804 https://leetcode-cn.com/problems/implement-trie-ii-prefix-
copypasta/trie.go:170
Function
countSubIslands
(grid1, grid2 [][]int)
leetcode/weekly/246/c/c.go:13
Function
countSubTrees
(n int, edges [][]int, s string)
leetcode/weekly/198/b/b.go:3
Function
countSubgraphsForEachDiameter
github.com/EndlessCheng/codeforces-go
leetcode/weekly/210/d/d.go:4
Function
countSubstrings
注:复杂度 O(nm) 的做法: 定义 dp[i][j] 表示以 s[i] 和 t[j] 结尾的所有子串对中,恰好只有一个字符不同的子串对的数目 github.com/EndlessCheng/codeforces-go
leetcode/biweekly/38/c/c.go:7
← previous
next →
6,501–6,600 of 8,098, ranked by callers