union_find
Reviewed
TODO
200.Number-of-Islands (H-) 305.Number-of-Islands-II (H-) 130.Surrounded-Regions (H-) 128.Longest-Consecutive-Sequence (H-) 684.Redundant-Connection (M) 685.Redundant-Connection-II (H) 721.Accounts-Merge (M+) 765.Couples-Holding-Hands (H-) 785.Is-Graph-Bipartite (M+) 924.Minimize-Malware-Spread (H-) 947.Most-Stones-Removed-with-Same-Row-or-Column (M+) 959.Regions-Cut-By-Slashes (H-) 990.Satisfiability-of-Equality-Equations (M+) 1061.Lexicographically-Smallest-Equivalent-String (M) 1101.The-Earliest-Moment-When-Everyone-Become-Friends (M+) 1202.Smallest-String-With-Swaps (M+) 1319.Number-of-Operations-to-Make-Network-Connected (M+) 1632.Rank-Transform-of-a-Matrix (H) 1631.Path-With-Minimum-Effort (H-) 1724.Checking-Existence-of-Edge-Length-Limited-Paths-II (H+) 1722.Minimize-Hamming-Distance-After-Swap-Operations (M+) 803.Bricks-Falling-When-Hit (H) 1970.Last-Day-Where-You-Can-Still-Cross (H-)
Patterns
Suitable in a dynamically changing graph.
Complexity: O(lgn)
Example problems: Number of Island II, find weakly connected components in directed graph, find connected components in undirected graph
Prime Factors
952.Largest-Component-Size-by-Common-Factor (H) 1627.Graph-Connectivity-With-Threshold (M+) 1998.GCD-Sort-of-an-Array (H-)
MST
1135.Connecting-Cities-With-Minimum-Cost (M+) 1168.Optimize-Water-Distribution-in-a-Village (H-) 1489.Find-Critical-and-Pseudo-Critical-Edges-in-Minimum-Spanning-Tree (H) 1579.Remove-Max-Number-of-Edges-to-Keep-Graph-Fully-Traversable (H-) 1584.Min-Cost-to-Connect-All-Points (H-)
Last updated