AIInterviewTraining logoAIInterview/Training
💻 Coding & Engineering Craft
Core

Union-Find (Disjoint Set Union)

Union-Find (Disjoint Set Union) maintains a partition of elements into groups and answers 'are these two connected?' in near-constant amortized time via path compression and union by rank. Interviews test it because the naive alternative (re-running DFS or BFS per query) is too slow when merges repeat, and DSU is the right tool for dynamic connectivity, Kruskal's MST, and grouping problems where edges show up over time.

a free account unlocks the core curriculum tier · no card
RELATED CONCEPTS
PRACTICE THIS IN REAL QUESTIONS
COMPANIES THAT ASSUME THIS
NEXT IN CODING & ENGINEERING CRAFTRecursion and Divide-and-Conquer