并查集题目汇总

视频讲解:
https://www.bilibili.com/video/BV1Le4y1R7xu?t=1289.1

// 模版
n := len(nums)
fa := make([]int, n+1)
for i := range fa {
	fa[i] = i
}
var find func(int) int
find = func(x int) int {
	if fa[x] != x {
		fa[x] = find(fa[x])
	}
	return fa[x]
}

leetcode算法题–元素值大于变化阈值的子数组、视频教程
leetcode算法题–找出最安全路径、视频教程

你可能感兴趣的:(Algorithm,leetcode,算法)