What is Union Find and what problems does it solve?
LeetCode Patterns Flashcards: Graphs, BFS, DFS, Topological Sort, Union Find
Аудио-карточка · 0:26Nortren·
What is Union Find and what problems does it solve?
0:26
Union Find, also called Disjoint Set Union, maintains a collection of disjoint sets and supports two operations: find, which determines which set an element belongs to, and union, which merges two sets. With path compression in find and union by rank, both operations run in nearly O of one amortized time. Union Find efficiently solves connected component problems, cycle detection in undirected graphs, Kruskal's minimum spanning tree algorithm, and determining if two nodes are in the same group.
neetcode.io