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]

Trie Template Guide: Node Fields, Child Traversal, and Loop Invariants

Subtitle / Summary Build a Trie from a small word-index task instead of memorizing the final class. The key model is: a node represents a prefix reached by a path, and is_end decides whether that prefix is also a complete word. Reading time: 10-12 min Tags: Hot100, Trie, prefix tree, string SEO keywords: Trie template, Python Trie, prefix tree, children, is_end, LeetCode 208 Meta description: A minimal Python Trie template that derives node fields, child traversal, end markers, prefix search, and insert/search loop invariants. A - Algorithm: Start From A Small Task Tiny task: build a word index for lookup and autocomplete Suppose we are building a small word index for a search box. After adding: ...

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