The Minimum Cost to Connect Two Groups of Points problem gives you two groups of points, and a cost matrix where cost[i][j] is the cost to connect point i from the first group with point j from the second group. You need to find the minimum cost to connect every point in both groups to at least one point in the other group.
This is a high-level Minimum Cost to Connect Groups interview question at Google. It is a classic Bitmask Dynamic Programming problem. It tests if a candidate can handle asymmetrical constraints where one group is small enough (e.g., up to 12 points) to be represented as a bitmask. It evaluates complex state management and optimization.
The Bitmask DP interview pattern is required.
dp[i][mask] be the minimum cost to connect the first i points of group 1, where mask represents the set of points in group 2 that have been connected.i in group 1, you can connect it to any point j in group 2, or even a subset of points.Group 1: {A, B}, Group 2: {X, Y}. Costs: A-X=1, A-Y=5, B-X=5, B-Y=1.
{X}.{X, Y}.Whenever you see a problem with a very small constraint (like 10-15) on one of the inputs, think of Bitmasks. Practicing Bitmask DP is a great way to prepare for "hard" level interviews at top-tier tech companies.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Maximum Students Taking Exam | Hard | Solve | |
| Find the Minimum Cost Array Permutation | Hard | Solve | |
| Maximum AND Sum of Array | Hard | Solve | |
| Smallest Sufficient Team | Hard | Solve | |
| Concatenated Divisibility | Hard | Solve |