![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
并查集/Union Find
景行cmy
这个作者很懒,什么都没留下…
展开
-
leetcode 928. Minimize Malware Spread II
(This problem is the same asMinimize Malware Spread, with the differences bolded.)In a network of nodes, each nodeiis directly connected to another nodejif and only ifgraph[i][j] = 1.Some no...原创 2019-11-05 16:00:09 · 269 阅读 · 0 评论 -
leetcode 685 冗余链接
在本问题中,有根树指满足以下条件的有向图。该树只有一个根节点,所有其他节点都是该根节点的后继。每一个节点只有一个父节点,除了根节点没有父节点。输入一个有向图,该图由一个有着N个节点 (节点值不重复1, 2, ..., N) 的树及一条附加的边构成。附加的边的两个顶点包含在1到N中间,这条附加的边不属于树中已存在的边。结果图是一个以边组成的二维数组。 每一个边 的元素是一对 [u, v],用...原创 2019-07-05 20:58:00 · 223 阅读 · 0 评论 -
leetcode 839. Similar String Groups
Two stringsXandYare similar if we can swap two letters (in different positions) ofX, so thatit equalsY.For example,"tars"and"rats"are similar (swapping at positions0and2), and"rats"an...原创 2019-07-29 15:50:38 · 317 阅读 · 0 评论 -
leetcode 952. Largest Component Size by Common Factor
Given a non-emptyarray of unique positive integersA, consider the following graph:There areA.lengthnodes, labelledA[0]toA[A.length - 1]; There is an edge betweenA[i]andA[j]if and only if...原创 2019-07-30 16:40:29 · 229 阅读 · 0 评论 -
leetcode 803. Bricks Falling When Hit
这道题见鬼的我连题目都没有读懂。。。郁闷。。。。这道题我用深度优先遍历坐的,当然超时了。。。We have a grid of 1s and 0s; the 1s in a cell represent bricks. A brick will not drop if and only if it is directly connected to the top of the grid,...原创 2019-07-30 17:06:39 · 291 阅读 · 0 评论 -
leetcode 749. Contain Virus
A virus is spreading rapidly, and your task is to quarantine the infected area by installing walls.The world is modeled as a 2-D array of cells, where0represents uninfected cells, and1represents...原创 2019-08-20 14:04:44 · 217 阅读 · 0 评论 -
leetcode 827. Making A Large Island
In a 2D grid of0s and1s, we change at most one0to a1.After, what is the size of the largest island?(An island is a 4-directionally connected group of1s).Example 1:Input: [[1, 0], [0, 1]]...原创 2019-08-26 17:23:21 · 157 阅读 · 0 评论