# Union-Find DSA Problems

> 91 Union-Find coding problems for placements and interviews, sorted easiest first, with hints and company tags. Free practice on InternHack.

Canonical: https://www.internhack.in/learn/dsa/union-find
Last updated: 2026-11-28

91 union-find problems for coding interviews and campus placements, with hints and company tags. Below are all 91: 1 easy, 49 medium and 41 hard. Practise them free on InternHack and track what you have solved.

## Union-Find problems, easiest first

1. [Find if Path Exists in Graph](https://www.internhack.in/learn/dsa/problem/find-if-path-exists-in-graph) (Easy)
2. [Accounts Merge](https://www.internhack.in/learn/dsa/problem/accounts-merge) (Medium)
3. [Check if There is a Valid Path in a Grid](https://www.internhack.in/learn/dsa/problem/check-if-there-is-a-valid-path-in-a-grid) (Medium)
4. [Connecting Cities With Minimum Cost](https://www.internhack.in/learn/dsa/problem/connecting-cities-with-minimum-cost) (Medium)
5. [Count Islands With Total Value Divisible by K](https://www.internhack.in/learn/dsa/problem/count-islands-with-total-value-divisible-by-k) (Medium)
6. [Count Servers that Communicate](https://www.internhack.in/learn/dsa/problem/count-servers-that-communicate) (Medium)
7. [Count Sub Islands](https://www.internhack.in/learn/dsa/problem/count-sub-islands) (Medium)
8. [Count the Number of Complete Components](https://www.internhack.in/learn/dsa/problem/count-the-number-of-complete-components) (Medium)
9. [Count Unreachable Pairs of Nodes in an Undirected Graph](https://www.internhack.in/learn/dsa/problem/count-unreachable-pairs-of-nodes-in-an-undirected-graph) (Medium)
10. [Detect Cycles in 2D Grid](https://www.internhack.in/learn/dsa/problem/detect-cycles-in-2d-grid) (Medium)
11. [Evaluate Division](https://www.internhack.in/learn/dsa/problem/evaluate-division) (Medium)
12. [Find the Safest Path in a Grid](https://www.internhack.in/learn/dsa/problem/find-the-safest-path-in-a-grid) (Medium)
13. [Graph Valid Tree](https://www.internhack.in/learn/dsa/problem/graph-valid-tree) (Medium)
14. [Is Graph Bipartite?](https://www.internhack.in/learn/dsa/problem/is-graph-bipartite) (Medium)
15. [Lexicographically Smallest Equivalent String](https://www.internhack.in/learn/dsa/problem/lexicographically-smallest-equivalent-string) (Medium)
16. [Longest Consecutive Sequence](https://www.internhack.in/learn/dsa/problem/longest-consecutive-sequence) (Medium)
17. [Longest Uploaded Prefix](https://www.internhack.in/learn/dsa/problem/longest-uploaded-prefix) (Medium)
18. [Make Lexicographically Smallest Array by Swapping Elements](https://www.internhack.in/learn/dsa/problem/make-lexicographically-smallest-array-by-swapping-elements) (Medium)
19. [Max Area of Island](https://www.internhack.in/learn/dsa/problem/max-area-of-island) (Medium)
20. [Maximum Number of Fish in a Grid](https://www.internhack.in/learn/dsa/problem/maximum-number-of-fish-in-a-grid) (Medium)
21. [Min Cost to Connect All Points](https://www.internhack.in/learn/dsa/problem/min-cost-to-connect-all-points) (Medium)
22. [Minimize Hamming Distance After Swap Operations](https://www.internhack.in/learn/dsa/problem/minimize-hamming-distance-after-swap-operations) (Medium)
23. [Minimize Maximum Component Cost](https://www.internhack.in/learn/dsa/problem/minimize-maximum-component-cost) (Medium)
24. [Minimum Score of a Path Between Two Cities](https://www.internhack.in/learn/dsa/problem/minimum-score-of-a-path-between-two-cities) (Medium)
25. [Minimum Time for K Connected Components](https://www.internhack.in/learn/dsa/problem/minimum-time-for-k-connected-components) (Medium)
26. [Most Stones Removed with Same Row or Column](https://www.internhack.in/learn/dsa/problem/most-stones-removed-with-same-row-or-column) (Medium)
27. [Number of Closed Islands](https://www.internhack.in/learn/dsa/problem/number-of-closed-islands) (Medium)
28. [Number of Connected Components in an Undirected Graph](https://www.internhack.in/learn/dsa/problem/number-of-connected-components-in-an-undirected-graph) (Medium)
29. [Number of Distinct Islands](https://www.internhack.in/learn/dsa/problem/number-of-distinct-islands) (Medium)
30. [Number of Enclaves](https://www.internhack.in/learn/dsa/problem/number-of-enclaves) (Medium)
31. [Number of Islands](https://www.internhack.in/learn/dsa/problem/number-of-islands) (Medium)
32. [Number of Operations to Make Network Connected](https://www.internhack.in/learn/dsa/problem/number-of-operations-to-make-network-connected) (Medium)
33. [Number of Provinces](https://www.internhack.in/learn/dsa/problem/number-of-provinces) (Medium)
34. [Number of Unique Categories](https://www.internhack.in/learn/dsa/problem/number-of-unique-categories) (Medium)
35. [Path Existence Queries in a Graph I](https://www.internhack.in/learn/dsa/problem/path-existence-queries-in-a-graph-i) (Medium)
36. [Path With Maximum Minimum Value](https://www.internhack.in/learn/dsa/problem/path-with-maximum-minimum-value) (Medium)
37. [Path With Minimum Effort](https://www.internhack.in/learn/dsa/problem/path-with-minimum-effort) (Medium)
38. [Possible Bipartition](https://www.internhack.in/learn/dsa/problem/possible-bipartition) (Medium)
39. [Power Grid Maintenance](https://www.internhack.in/learn/dsa/problem/power-grid-maintenance) (Medium)
40. [Reachable Nodes With Restrictions](https://www.internhack.in/learn/dsa/problem/reachable-nodes-with-restrictions) (Medium)
41. [Redundant Connection](https://www.internhack.in/learn/dsa/problem/redundant-connection) (Medium)
42. [Regions Cut By Slashes](https://www.internhack.in/learn/dsa/problem/regions-cut-by-slashes) (Medium)
43. [Satisfiability of Equality Equations](https://www.internhack.in/learn/dsa/problem/satisfiability-of-equality-equations) (Medium)
44. [Sentence Similarity II](https://www.internhack.in/learn/dsa/problem/sentence-similarity-ii) (Medium)
45. [Smallest String With Swaps](https://www.internhack.in/learn/dsa/problem/smallest-string-with-swaps) (Medium)
46. [Sum of Remoteness of All Cells](https://www.internhack.in/learn/dsa/problem/sum-of-remoteness-of-all-cells) (Medium)
47. [Surrounded Regions](https://www.internhack.in/learn/dsa/problem/surrounded-regions) (Medium)
48. [Synonymous Sentences](https://www.internhack.in/learn/dsa/problem/synonymous-sentences) (Medium)
49. [The Earliest Moment When Everyone Become Friends](https://www.internhack.in/learn/dsa/problem/the-earliest-moment-when-everyone-become-friends) (Medium)
50. [Validate Binary Tree Nodes](https://www.internhack.in/learn/dsa/problem/validate-binary-tree-nodes) (Medium)
51. [Bricks Falling When Hit](https://www.internhack.in/learn/dsa/problem/bricks-falling-when-hit) (Hard)
52. [Check for Contradictions in Equations](https://www.internhack.in/learn/dsa/problem/check-for-contradictions-in-equations) (Hard)
53. [Check if the Rectangle Corner Is Reachable](https://www.internhack.in/learn/dsa/problem/check-if-the-rectangle-corner-is-reachable) (Hard)
54. [Checking Existence of Edge Length Limited Paths](https://www.internhack.in/learn/dsa/problem/checking-existence-of-edge-length-limited-paths) (Hard)
55. [Checking Existence of Edge Length Limited Paths II](https://www.internhack.in/learn/dsa/problem/checking-existence-of-edge-length-limited-paths-ii) (Hard)
56. [Couples Holding Hands](https://www.internhack.in/learn/dsa/problem/couples-holding-hands) (Hard)
57. [Data Stream as Disjoint Intervals](https://www.internhack.in/learn/dsa/problem/data-stream-as-disjoint-intervals) (Hard)
58. [Divide Nodes Into the Maximum Number of Groups](https://www.internhack.in/learn/dsa/problem/divide-nodes-into-the-maximum-number-of-groups) (Hard)
59. [Find All People With Secret](https://www.internhack.in/learn/dsa/problem/find-all-people-with-secret) (Hard)
60. [Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree](https://www.internhack.in/learn/dsa/problem/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) (Hard)
61. [Find the String with LCP](https://www.internhack.in/learn/dsa/problem/find-the-string-with-lcp) (Hard)
62. [GCD Sort of an Array](https://www.internhack.in/learn/dsa/problem/gcd-sort-of-an-array) (Hard)
63. [Graph Connectivity With Threshold](https://www.internhack.in/learn/dsa/problem/graph-connectivity-with-threshold) (Hard)
64. [Groups of Strings](https://www.internhack.in/learn/dsa/problem/groups-of-strings) (Hard)
65. [Largest Component Size by Common Factor](https://www.internhack.in/learn/dsa/problem/largest-component-size-by-common-factor) (Hard)
66. [Last Day Where You Can Still Cross](https://www.internhack.in/learn/dsa/problem/last-day-where-you-can-still-cross) (Hard)
67. [Making A Large Island](https://www.internhack.in/learn/dsa/problem/making-a-large-island) (Hard)
68. [Maximize Alternating Sum Using Swaps](https://www.internhack.in/learn/dsa/problem/maximize-alternating-sum-using-swaps) (Hard)
69. [Maximum Number of Points From Grid Queries](https://www.internhack.in/learn/dsa/problem/maximum-number-of-points-from-grid-queries) (Hard)
70. [Maximum Partition Factor](https://www.internhack.in/learn/dsa/problem/maximum-partition-factor) (Hard)
71. [Maximum Segment Sum After Removals](https://www.internhack.in/learn/dsa/problem/maximum-segment-sum-after-removals) (Hard)
72. [Minimize Malware Spread](https://www.internhack.in/learn/dsa/problem/minimize-malware-spread) (Hard)
73. [Minimize Malware Spread II](https://www.internhack.in/learn/dsa/problem/minimize-malware-spread-ii) (Hard)
74. [Minimize Maximum Value in a Grid](https://www.internhack.in/learn/dsa/problem/minimize-maximum-value-in-a-grid) (Hard)
75. [Minimum Cost Walk in Weighted Graph](https://www.internhack.in/learn/dsa/problem/minimum-cost-walk-in-weighted-graph) (Hard)
76. [Minimum Number of Visited Cells in a Grid](https://www.internhack.in/learn/dsa/problem/minimum-number-of-visited-cells-in-a-grid) (Hard)
77. [Minimum Operations to Equalize Binary String](https://www.internhack.in/learn/dsa/problem/minimum-operations-to-equalize-binary-string) (Hard)
78. [Minimum Reverse Operations](https://www.internhack.in/learn/dsa/problem/minimum-reverse-operations) (Hard)
79. [Minimum Runes to Add to Cast Spell](https://www.internhack.in/learn/dsa/problem/minimum-runes-to-add-to-cast-spell) (Hard)
80. [Number of Distinct Islands II](https://www.internhack.in/learn/dsa/problem/number-of-distinct-islands-ii) (Hard)
81. [Number of Good Paths](https://www.internhack.in/learn/dsa/problem/number-of-good-paths) (Hard)
82. [Number of Islands II](https://www.internhack.in/learn/dsa/problem/number-of-islands-ii) (Hard)
83. [Number of Ways to Reorder Array to Get Same BST](https://www.internhack.in/learn/dsa/problem/number-of-ways-to-reorder-array-to-get-same-bst) (Hard)
84. [Optimize Water Distribution in a Village](https://www.internhack.in/learn/dsa/problem/optimize-water-distribution-in-a-village) (Hard)
85. [Process Restricted Friend Requests](https://www.internhack.in/learn/dsa/problem/process-restricted-friend-requests) (Hard)
86. [Rank Transform of a Matrix](https://www.internhack.in/learn/dsa/problem/rank-transform-of-a-matrix) (Hard)
87. [Redundant Connection II](https://www.internhack.in/learn/dsa/problem/redundant-connection-ii) (Hard)
88. [Remove Max Number of Edges to Keep Graph Fully Traversable](https://www.internhack.in/learn/dsa/problem/remove-max-number-of-edges-to-keep-graph-fully-traversable) (Hard)
89. [Similar String Groups](https://www.internhack.in/learn/dsa/problem/similar-string-groups) (Hard)
90. [Subarray With Elements Greater Than Varying Threshold](https://www.internhack.in/learn/dsa/problem/subarray-with-elements-greater-than-varying-threshold) (Hard)
91. [Swim in Rising Water](https://www.internhack.in/learn/dsa/problem/swim-in-rising-water) (Hard)

## Companies that ask union-find problems

- [Google](https://www.internhack.in/learn/dsa/companies/google): 73 of these problems
- [Amazon](https://www.internhack.in/learn/dsa/companies/amazon): 56 of these problems
- [Meta](https://www.internhack.in/learn/dsa/companies/meta): 40 of these problems
- [Microsoft](https://www.internhack.in/learn/dsa/companies/microsoft): 35 of these problems
- [Uber](https://www.internhack.in/learn/dsa/companies/uber): 28 of these problems
- [Bloomberg](https://www.internhack.in/learn/dsa/companies/bloomberg): 25 of these problems
- [Tiktok](https://www.internhack.in/learn/dsa/companies/tiktok): 18 of these problems
- [Phonepe](https://www.internhack.in/learn/dsa/companies/phonepe): 10 of these problems
- [Linkedin](https://www.internhack.in/learn/dsa/companies/linkedin): 10 of these problems
- [Oracle](https://www.internhack.in/learn/dsa/companies/oracle): 9 of these problems
- [Apple](https://www.internhack.in/learn/dsa/companies/apple): 9 of these problems
- [Snapchat](https://www.internhack.in/learn/dsa/companies/snapchat): 8 of these problems

## Before your interview

Most resumes are filtered by software before a recruiter reads them. [Check your resume ATS score free](https://www.internhack.in/ats-score/try), no signup needed.

## Other DSA topics

- [Array](https://www.internhack.in/learn/dsa/array) (1869)
- [String](https://www.internhack.in/learn/dsa/string) (775)
- [Hash Table](https://www.internhack.in/learn/dsa/hash-table) (708)
- [Math](https://www.internhack.in/learn/dsa/math) (564)
- [Dynamic Programming](https://www.internhack.in/learn/dsa/dynamic-programming) (557)
- [Sorting](https://www.internhack.in/learn/dsa/sorting) (464)
- [Greedy](https://www.internhack.in/learn/dsa/greedy) (407)
- [Depth-First Search](https://www.internhack.in/learn/dsa/depth-first-search) (314)
- [Binary Search](https://www.internhack.in/learn/dsa/binary-search) (298)
- [Matrix](https://www.internhack.in/learn/dsa/matrix) (246)
- [Breadth-First Search](https://www.internhack.in/learn/dsa/breadth-first-search) (245)
- [Bit Manipulation](https://www.internhack.in/learn/dsa/bit-manipulation) (238)
- [Tree](https://www.internhack.in/learn/dsa/tree) (235)
- [Two Pointers](https://www.internhack.in/learn/dsa/two-pointers) (217)
- [Prefix Sum](https://www.internhack.in/learn/dsa/prefix-sum) (204)
- [Database](https://www.internhack.in/learn/dsa/database) (197)
- [Heap (Priority Queue)](https://www.internhack.in/learn/dsa/heap-priority-queue) (196)
- [Simulation](https://www.internhack.in/learn/dsa/simulation) (177)
- [Counting](https://www.internhack.in/learn/dsa/counting) (174)
- [Binary Tree](https://www.internhack.in/learn/dsa/binary-tree) (169)

## Related

- [Home](https://www.internhack.in/)
- [Learn](https://www.internhack.in/learn)
- [DSA](https://www.internhack.in/learn/dsa)
