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
minNumberOperations
(a []int)
leetcode/biweekly/31/d/d.go:3
Function
minOperations
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/33/c/c.go:6
Function
minOperations
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/50/a/a.go:4
Function
minOperations
* 排序+去重+二分 考虑最多可以保留多少个元素不变。由于元素的位置不影响答案,且要求所有元素互不相同,我们可以将 $\textit{nums}$ 排序,并去掉重复元素。 记原数组长度为 $n$。对排序去重后的 $\textit{nums}'$ 中的一段区间 $[l,r]$,若要保留这段区间内的
leetcode/biweekly/61/d/d.go:36
Function
minOperations
github.com/EndlessCheng/codeforces-go
leetcode/weekly/215/c/c.go:6
Function
minOperations
github.com/EndlessCheng/codeforces-go
leetcode/weekly/230/c/c.go:4
Function
minOperations
github.com/EndlessCheng/codeforces-go
leetcode/weekly/202/b/b.go:4
Function
minOperations
github.com/EndlessCheng/codeforces-go
leetcode/weekly/208/a/a.go:4
Function
minOperations
github.com/EndlessCheng/codeforces-go
leetcode/weekly/228/a/a.go:4
Function
minOperations
github.com/EndlessCheng/codeforces-go
leetcode/weekly/229/b/b.go:4
Function
minOperations
github.com/EndlessCheng/codeforces-go
leetcode/weekly/222/d/d.go:6
Function
minOperations
* 中位数 要使任意两元素最终相等,这两个元素之差必须是 $x$ 的倍数,否则无法通过加减 $x$ 来相等。 假设要让所有元素均为 $y$,可以发现: - $y$ 每增加 $x$,小于或等于 $y$ 的元素要多操作一次,大于 $y$ 的元素要少操作一次; - $y$ 每减小 $x$,大于或等于
leetcode/weekly/262/b/b.go:18
Function
minOperationsMaxProfit
github.com/EndlessCheng/codeforces-go
leetcode/weekly/208/b/b.go:4
Function
minOperationsToFlip
(s string)
leetcode/biweekly/54/d/d.go:6
Function
minPairSum
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/53/b/b.go:6
Function
minPartitions
github.com/EndlessCheng/codeforces-go
leetcode/weekly/219/b/b.go:4
Function
minPatches
LC 330 todo: 需要回顾
leetcode/main.go:1182
Method
minPathCover
树上最小路径覆盖,要求路径之间不相交,即每个顶点恰好被覆盖一次(路径长度可以为 0,即一个点) 贪心做法是对每个点及其子树,尽量让这个点能够拼接两个子树的路径,从而形成一条路径(把这个点当作「拐点」) DP 做法是定义 dp[i][0/1] 表示以 i 为根的子树的最小路径覆盖数,0 即 i 不与父
copypasta/graph_tree.go:213
Function
minPushBox
(g [][]byte)
leetcode/weekly/163/d/d.go:3
Function
minRemoveToMakeValid
(ss string)
leetcode/weekly/161/c/c.go:5
Function
minReorder
(n int, connections [][]int)
leetcode/weekly/191/c/c.go:3
Function
minSessions
* 子集动态规划 定义状态 $f[s]$ 表示完成任务集合 $s$ 的所有任务所需要的最少数目的工作时间段。 枚举 $s$ 的子集 $\textit{sub}$,若完成 $\textit{sub}$ 的所有任务耗时不超过 $\textit{sessionTime}$,则可以将 $f[s\setm
leetcode/weekly/256/c/c.go:21
Function
minSetSize
(arr []int)
leetcode/weekly/174/b/b.go:5
Function
minSideJumps
github.com/EndlessCheng/codeforces-go
leetcode/weekly/236/c/c.go:4
Function
minSkips
github.com/EndlessCheng/codeforces-go
leetcode/weekly/243/d/d.go:4
Function
minSpeedOnTime
github.com/EndlessCheng/codeforces-go
leetcode/weekly/242/b/b.go:9
Function
minStartValue
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/24/a/a.go:4
Function
minSteps
(s string, t string)
leetcode/weekly/175/b/b.go:3
Function
minStoneSum
github.com/EndlessCheng/codeforces-go
leetcode/weekly/253/b/b.go:9
Function
minSubArrayLen
LC 209
leetcode/main.go:916
Function
minSubarray
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/35/c/c.go:4
Function
minSubsequence
(a []int)
leetcode/weekly/183/a/a.go:5
Function
minSumOfLengths
(a []int, target int)
leetcode/biweekly/28/c/c.go:6
Function
minSwaps
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/6/b/b.go:4
Function
minSwaps
github.com/EndlessCheng/codeforces-go
leetcode/weekly/253/c/c.go:4
Function
minSwaps
github.com/EndlessCheng/codeforces-go
leetcode/weekly/200/c/c.go:4
Function
minSwaps
github.com/EndlessCheng/codeforces-go
leetcode/weekly/241/b/b.go:6
Function
minTaps
(n int, ranges []int)
leetcode/weekly/172/d/d.go:5
Function
minTime
(a []int, m int)
leetcode/season/2020spring2/b/b.go:5
Function
minTime
(n int, edges [][]int, has []bool)
leetcode/weekly/188/c/c.go:3
Function
minTimeToType
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/59/a/a.go:4
Function
minTimeToVisitAllPoints
(points [][]int)
leetcode/weekly/164/a/a.go:3
Function
minTrioDegree
github.com/EndlessCheng/codeforces-go
leetcode/weekly/228/d/d.go:4
Function
minWastedSpace
github.com/EndlessCheng/codeforces-go
leetcode/weekly/244/d/d.go:9
Function
mincostTickets
(days []int, costs []int)
leetcode/weekly/121/c/c.go:3
Function
mincostToHireWorkers
(quality []int, wage []int, k int)
leetcode/weekly/90/d/d.go:16
Function
minimalExecTime
(o *TreeNode)
leetcode/season/2020spring/e/e.go:5
Function
minimalSteps
(grids []string)
leetcode/season/2020spring2/c/c.go:3
Function
minimizeTheDifference
github.com/EndlessCheng/codeforces-go
leetcode/weekly/255/c/c.go:4
Function
minimizedMaximum
二分答案 github.com/EndlessCheng/codeforces-go
leetcode/weekly/266/c/c.go:8
Function
minimumAbsDifference
github.com/EndlessCheng/codeforces-go
leetcode/weekly/155/a/a.go:6
Function
minimumBoxes
(n int)
leetcode/weekly/225/d/d.go:18
Function
minimumBuckets
O(n) 一次遍历 + O(1) 空间 github.com/EndlessCheng/codeforces-go
leetcode/biweekly/66/b/b.go:6
Function
minimumCost
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/5/c/c.go:6
Method
minimumCutStoerWagner
无向图全局最小割 Stoer-Wagner 算法 O(nm+n^2logn) https://en.wikipedia.org/wiki/Stoer%E2%80%93Wagner_algorithm https://algs4.cs.princeton.edu/code/edu/princeton/
copypasta/graph.go:3578
Function
minimumDeletions
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/39/b/b.go:4
Function
minimumDeletions
* 三种贪心策略取最小值 根据题意,可以得到如下三种贪心策略: - 删除包含最小值和最大值的数组前缀; - 删除包含最小值和最大值的数组后缀; - 删除包含最小值的数组前缀(后缀),以及包含最大值的数组后缀(前缀)。 记数组长度为 $n$,最小值的位置为 $i$,最大值的位置为 $j$,假设
leetcode/weekly/269/c/c.go:22
Function
minimumDeviation
(a []int)
leetcode/weekly/217/d/d.go:15
Function
minimumDifference
排序+滑动窗口 github.com/EndlessCheng/codeforces-go
leetcode/weekly/256/a/a.go:11
Function
minimumDifference
* 折半枚举+排序+二分 两个数组和之差可以视作从 $\textit{nums}$ 中选 $n$ 个数取正号,其余 $n$ 个数取负号,然后求元素和。 我们可以使用折半枚举的方法,枚举 $\textit{nums}$ 的前 $n$ 个元素取正或取负的所有情况,按取正个数分组,并按照元素和排序。然
leetcode/weekly/262/d/d.go:17
Function
minimumDistance
(ss string)
leetcode/weekly/171/d/d.go:49
Function
minimumEffort
github.com/EndlessCheng/codeforces-go
leetcode/weekly/216/d/d.go:6
Function
minimumEffortPath
另外两个方法: - 从小到大加入并查集直至起终点在同一个集合 - dij,把 + 换成 max 从码量上来说最小的还是二分 github.com/EndlessCheng/codeforces-go
leetcode/weekly/212/c/c.go:12
Function
minimumHammingDistance
github.com/EndlessCheng/codeforces-go
leetcode/weekly/223/c/c.go:4
Function
minimumIncompatibility
github.com/EndlessCheng/codeforces-go
leetcode/weekly/218/d/d.go:6
Function
minimumJumps
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/39/c/c.go:4
Function
minimumMountainRemovals
(a []int)
leetcode/biweekly/40/d/d.go:22
Function
minimumMoves
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/12/d/d.go:4
Function
minimumMoves
* 贪心 遍历 $s$,遇到 $\texttt{X}$ 就将其与后面两个字符改为 $\texttt{O}$,操作次数加一,然后跳过后面两个字符。 */ github.com/EndlessCheng/codeforces-go
leetcode/weekly/261/a/a.go:9
Function
minimumOneBitOperations
github.com/EndlessCheng/codeforces-go
leetcode/weekly/209/d/d.go:4
Function
minimumOneBitOperations2
(n int)
leetcode/weekly/209/d/d.go:19
Function
minimumOperations
github.com/EndlessCheng/codeforces-go
leetcode/weekly/265/c/c.go:4
Function
minimumPerimeter
* 二分 二分边长的一半,我们需要计算出该正方形内的苹果个数。 我们可以找出每一圈的苹果个数公式,然后利用该公式累加。 对于左下角在 $(-i,-i)$,右上角在 $(i,i)$ 的这一圈苹果,将这一圈拆分成四角的 $4$ 个苹果树,坐标包含 $0$ 的 $4$ 个苹果树,由于对称性,其余苹果
leetcode/weekly/252/c/c.go:24
Function
minimumRefill
双指针模拟 github.com/EndlessCheng/codeforces-go
leetcode/weekly/271/c/c.go:6
Function
minimumSemesters
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/5/d/d.go:4
Function
minimumSize
github.com/EndlessCheng/codeforces-go
leetcode/weekly/228/c/c.go:6
Function
minimumSwap
0011010100 0110100010 xxyyxyxyxx xyyxyxxxyx xxyyyyxyxx xxyxyxxxyx xxyyyxxyxx xxyyyxxxyx
leetcode/weekly/161/a/a.go:16
Function
minimumSwitchingTimes
* 用哈希表统计差异 */ github.com/EndlessCheng/codeforces-go
leetcode/season/2021fall/a/a.go:9
Function
minimumTeachings
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/44/b/b.go:4
Function
minimumTime
* 拓扑排序 + 动态规划 定义 $f[i]$ 表示完成第 $i$ 门课程需要花费的最少月份数。根据题意,只有当 $i$ 的所有先修课程都完成时,才可以开始 $i$,并且我们可以立即开始 $i$。 因此 $f[i]=\textit{time}[i] + \max f[j]$,这里 $j$ 是 $
leetcode/weekly/264/d/d.go:22
Function
minimumTimeRequired
0 ms (https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs/discuss/1010057/Python-Binary-search-24ms)
leetcode/weekly/223/d/d.go:9
Function
minimumTimeRequiredDP
(a []int, k int)
leetcode/weekly/223/d/d.go:43
Function
minimumXORSum
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/53/d/d.go:6
Function
mirrorReflection
github.com/EndlessCheng/codeforces-go
leetcode/weekly/90/c/c.go:4
Function
miscCollection
* 其他无法分类的算法 三维 n 皇后 https://oeis.org/A068940 Maximal number of chess queens that can be placed on a 3-dimensional chessboard of order n so that no tw
copypasta/misc.go:51
Function
missingNumber
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/11/a/a.go:4
Function
missingRolls
* 模拟 根据题意,缺失的投掷数据之和为 $\textit{miss}=(n+m)\cdot \textit{mean}-\sum \textit{rolls}$ $\textit{miss}$ 最小为 $n$,对应均投掷为 $1$ 的情况,最大为 $6n$,对应均投掷为 $6$ 的情况,超出该
leetcode/weekly/261/b/b.go:14
Function
moAlgorithm
有关根号分解的说明另见 sqrt_decomposition.go 莫队算法:对询问分块 todo 各类莫队综述 https://www.cnblogs.com/WAMonster/p/10118934.html https://ouuan.github.io/post/%E8%8E%AB%E9%9
copypasta/mo.go:19
Method
mod
(b Int)
copypasta/big.go:24
Method
mod
多项式取模
copypasta/math_ntt.go:331
Function
modifyString
github.com/EndlessCheng/codeforces-go
leetcode/weekly/205/a/a.go:4
Method
mods
(b Int)
copypasta/big.go:15
Function
monotoneIncreasingDigits
LC 738 返回 <=N 的最大的非降整数
leetcode/main.go:1481
Function
monotoneQueueCollections
()
copypasta/monotone_queue.go:53
Function
monotoneStack
* 单调栈 Monotone Stack 举例:返回每个元素两侧严格大于它的元素位置(不存在则为 -1 或 n) 如何理解:把数组想象成一列山峰,站在 a[i] 的山顶仰望两侧的山峰,是看不到高山背后的矮山的,只能看到一座座更高的山峰 这就启发我们引入一个底大顶小的单调栈,入栈时不
copypasta/monotone_stack.go:38
Function
mostCompetitive
github.com/EndlessCheng/codeforces-go
leetcode/weekly/217/b/b.go:4
Function
mostVisited
github.com/EndlessCheng/codeforces-go
leetcode/weekly/203/a/a.go:4
Function
mostVisitedPattern
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/6/c/c.go:8
Function
mostWordsFound
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/68/a/a.go:6
Method
msaEdmonds
最小树形图 (MSA, Minimum weight Spanning Arborescence) O(nm) 朱刘算法(Edmonds 算法) todo 另外还有 Tarjan 的 O(m+nlogn) 算法 https://en.wikipedia.org/wiki/Edmonds%27_alg
copypasta/graph.go:2031
← previous
next →
7,501–7,600 of 8,098, ranked by callers