Relevant Patterns
#Study these pattern guides before tackling the problems. Understanding the core concepts will help you solve them more efficiently.
Practice Problems
#Medium#547
Show 2 hints
- Union cities with edges; count unique roots at the end.
- Alternatively BFS/DFS per component.
Medium#684
Show 2 hints
- Return first edge forming a cycle while unioning.
- Union‑by‑rank + path compression for near O(1).
Medium#721
Show 2 hints
- Union accounts by shared emails; group by root and sort addresses.
- Map email → id; careful with name grouping.
Medium#947
Show 2 hints
- Union by row/col keys; answer = n - number of components.
- Coordinate compression on rows/cols to single DSU space.
Medium#1202
Show 2 hints
- Union index pairs; sort characters within each component and rebuild string.
- Min‑heap per component to pop smallest letters.
Track Your Progress
Mark problems as complete as you solve them. Come back anytime to continue where you left off.