LeetCodechevron_rightSolve patternschevron_rightunion find
schemaReusable solving pattern

union find Pattern

Pattern hubs are for building transferable solving frames. Learn the recognition signals first, then drill state definition, update rules, and edge explanation until the pattern feels stable.

database11 problemstune0/3/8 difficulty mixcategory6 linked topics

Pattern brief

Recognize first

Tests the candidate's ability to handle grid manipulation using efficient data structures like Union Find.

Solve rhythm

State the active state and invariant first, explain how each update preserves them, then pressure-test with counterexamples.

Most common miss

Forgetting to reverse the hits and restoring the grid before processing each hit.

Recognition signals

  • Tests the candidate's ability to handle grid manipulation using efficient data structures like Union Find.
  • Assesses the candidate's understanding of graph connectivity and the impact of sequential modifications on data structures.
  • Candidate recognizes transitive equivalence and applies union find correctly.

Solve flow

  1. 1. Define the active state/window.
  2. 2. Update state while preserving invariants.
  3. 3. Validate with edge-heavy examples.

Common misses

  • Forgetting to reverse the hits and restoring the grid before processing each hit.
  • Failing to merge equivalence groups correctly and violating transitive relations.
  • Failing to sort edges before applying Union Find can give incorrect MST weight.

Recommended Ladder

Problem bank

union find pattern bank

Start by scanning with search or difficulty filters, then narrow by linked topics. The bank continues loading inside its own container so the page stays readable.

Progressive pattern bank

Use it to build pattern understanding first, then expand into the full corpus.

hourglass_bottomScroll inside to continue
search
tuneDifficulty
categoryTopic focus

Showing 11 / 11 problems

#TitleDifficulty
803

Bricks Falling When Hit

Bricks Falling When Hit challenges your ability to simulate brick falls after sequential erasures using Union Find.

Hard
1061

Lexicographically Smallest Equivalent String

Determine the lexicographically smallest string by modeling character equivalences with union find efficiently.

Medium
1489

Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree

Identify critical and pseudo-critical edges in a weighted graph's minimum spanning tree using Union Find efficiently.

Hard
1579

Remove Max Number of Edges to Keep Graph Fully Traversable

Maximize the number of edges that can be removed while keeping the graph fully traversable for both Alice and Bob.

Hard
1584

Min Cost to Connect All Points

Min Cost to Connect All Points asks for the minimum cost to connect all points on a 2D plane, using manhattan distances …

Medium
1632

Rank Transform of a Matrix

Compute a unique rank matrix using graph indegree with topological ordering, ensuring each element reflects its relative…

Hard
2076

Process Restricted Friend Requests

Determine which friend requests can be accepted without violating direct or indirect restrictions using union-find logic…

Hard
2157

Groups of Strings

Group words into connected sets using operations on characters with string and bit manipulation techniques.

Hard
2382

Maximum Segment Sum After Removals

Calculate the maximum segment sum after sequential removals using array plus union find for efficient merging of segment…

Hard
2948

Make Lexicographically Smallest Array by Swapping Elements

Solve the problem of making an array lexicographically smallest through element swaps under a limit constraint.

Medium
3108

Minimum Cost Walk in Weighted Graph

Find the minimum cost walk in a weighted graph using array and bit manipulation techniques for efficient path calculatio…

Hard

Continue by topic

Once the pattern itself feels familiar, move back into concrete topic hubs so you can separate the pattern from the changing problem context.

route

Guided Practice Path

AI recommends problems by your level and tracks your progress.

Start Guided Patharrow_forward
Array plus Union Find LeetCode Pattern: 11 Solutions