LeetCode 200: Number of Islands With Union-Find

Subtitle / Summary Do not start this problem by memorizing a Union-Find template. Start from the pressure: each land cell looks like one island at first, but adjacent land cells must collapse into one connected component. Reading time: 10-12 min Tags: Hot100, Union-Find, DSU, matrix, connected components SEO keywords: LeetCode 200, Number of Islands, Union-Find, DSU, connected components Meta description: A pressure-first Python guide to LeetCode 200 that derives land-only count, 2D-to-1D ids, Union-Find merges, and the final runnable solution. Problem Requirement You are given an m x n 2D character grid: ...

July 2, 2026 · 7 min · map[name:Jeanphilo]

LeetCode 684: Redundant Connection With Union-Find

Subtitle / Summary The key signal in this problem is not a component count. It is a failed union: if two endpoints are already connected, adding the current edge closes a cycle. Reading time: 8-10 min Tags: Union-Find, DSU, graph, tree, cycle detection SEO keywords: LeetCode 684, Redundant Connection, Union-Find, DSU, cycle detection Meta description: A pressure-first Python guide to LeetCode 684 that derives 1-indexed Union-Find, bool-returning union, ordered edge scanning, and final checks. Problem Requirement You are given an undirected graph. It started as a tree with n nodes labeled from 1 to n, then one extra edge was added. ...

July 2, 2026 · 7 min · map[name:Jeanphilo]

Union-Find Template: Derive find / union / count

Subtitle / Summary Union-Find is not a pair of function names to memorize first. It solves one concrete problem: decide whether two nodes already belong to the same set, and merge two sets when a connection appears. Reading time: 10-12 min Tags: Hot100, Union-Find, DSU, graph, connectivity SEO keywords: Union-Find, DSU, Disjoint Set Union, find, union, count, path compression Meta description: A Python Union-Find template guide that derives parent, find, union, count, connected, path compression, and connected component counting. A - Algorithm: Start From Set-Merging Pressure Tiny task: merge sets and answer connectivity Suppose we have 5 nodes: ...

June 30, 2026 · 10 min · map[name:Jeanphilo]