Union-Find DSA Problems

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 (Easy)
  2. Accounts Merge (Medium)
  3. Check if There is a Valid Path in a Grid (Medium)
  4. Connecting Cities With Minimum Cost (Medium)
  5. Count Islands With Total Value Divisible by K (Medium)
  6. Count Servers that Communicate (Medium)
  7. Count Sub Islands (Medium)
  8. Count the Number of Complete Components (Medium)
  9. Count Unreachable Pairs of Nodes in an Undirected Graph (Medium)
  10. Detect Cycles in 2D Grid (Medium)
  11. Evaluate Division (Medium)
  12. Find the Safest Path in a Grid (Medium)
  13. Graph Valid Tree (Medium)
  14. Is Graph Bipartite? (Medium)
  15. Lexicographically Smallest Equivalent String (Medium)
  16. Longest Consecutive Sequence (Medium)
  17. Longest Uploaded Prefix (Medium)
  18. Make Lexicographically Smallest Array by Swapping Elements (Medium)
  19. Max Area of Island (Medium)
  20. Maximum Number of Fish in a Grid (Medium)
  21. Min Cost to Connect All Points (Medium)
  22. Minimize Hamming Distance After Swap Operations (Medium)
  23. Minimize Maximum Component Cost (Medium)
  24. Minimum Score of a Path Between Two Cities (Medium)
  25. Minimum Time for K Connected Components (Medium)
  26. Most Stones Removed with Same Row or Column (Medium)
  27. Number of Closed Islands (Medium)
  28. Number of Connected Components in an Undirected Graph (Medium)
  29. Number of Distinct Islands (Medium)
  30. Number of Enclaves (Medium)
  31. Number of Islands (Medium)
  32. Number of Operations to Make Network Connected (Medium)
  33. Number of Provinces (Medium)
  34. Number of Unique Categories (Medium)
  35. Path Existence Queries in a Graph I (Medium)
  36. Path With Maximum Minimum Value (Medium)
  37. Path With Minimum Effort (Medium)
  38. Possible Bipartition (Medium)
  39. Power Grid Maintenance (Medium)
  40. Reachable Nodes With Restrictions (Medium)
  41. Redundant Connection (Medium)
  42. Regions Cut By Slashes (Medium)
  43. Satisfiability of Equality Equations (Medium)
  44. Sentence Similarity II (Medium)
  45. Smallest String With Swaps (Medium)
  46. Sum of Remoteness of All Cells (Medium)
  47. Surrounded Regions (Medium)
  48. Synonymous Sentences (Medium)
  49. The Earliest Moment When Everyone Become Friends (Medium)
  50. Validate Binary Tree Nodes (Medium)
  51. Bricks Falling When Hit (Hard)
  52. Check for Contradictions in Equations (Hard)
  53. Check if the Rectangle Corner Is Reachable (Hard)
  54. Checking Existence of Edge Length Limited Paths (Hard)
  55. Checking Existence of Edge Length Limited Paths II (Hard)
  56. Couples Holding Hands (Hard)
  57. Data Stream as Disjoint Intervals (Hard)
  58. Divide Nodes Into the Maximum Number of Groups (Hard)
  59. Find All People With Secret (Hard)
  60. Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree (Hard)
  61. Find the String with LCP (Hard)
  62. GCD Sort of an Array (Hard)
  63. Graph Connectivity With Threshold (Hard)
  64. Groups of Strings (Hard)
  65. Largest Component Size by Common Factor (Hard)
  66. Last Day Where You Can Still Cross (Hard)
  67. Making A Large Island (Hard)
  68. Maximize Alternating Sum Using Swaps (Hard)
  69. Maximum Number of Points From Grid Queries (Hard)
  70. Maximum Partition Factor (Hard)
  71. Maximum Segment Sum After Removals (Hard)
  72. Minimize Malware Spread (Hard)
  73. Minimize Malware Spread II (Hard)
  74. Minimize Maximum Value in a Grid (Hard)
  75. Minimum Cost Walk in Weighted Graph (Hard)
  76. Minimum Number of Visited Cells in a Grid (Hard)
  77. Minimum Operations to Equalize Binary String (Hard)
  78. Minimum Reverse Operations (Hard)
  79. Minimum Runes to Add to Cast Spell (Hard)
  80. Number of Distinct Islands II (Hard)
  81. Number of Good Paths (Hard)
  82. Number of Islands II (Hard)
  83. Number of Ways to Reorder Array to Get Same BST (Hard)
  84. Optimize Water Distribution in a Village (Hard)
  85. Process Restricted Friend Requests (Hard)
  86. Rank Transform of a Matrix (Hard)
  87. Redundant Connection II (Hard)
  88. Remove Max Number of Edges to Keep Graph Fully Traversable (Hard)
  89. Similar String Groups (Hard)
  90. Subarray With Elements Greater Than Varying Threshold (Hard)
  91. Swim in Rising Water (Hard)

Companies that ask union-find problems

Before your interview

Most resumes are filtered by software before a recruiter reads them. Check your resume ATS score free, no signup needed.

Other DSA topics