Practice Minimum Cost to Connect Two Groups of Points
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Minimum Cost to Connect Two Groups of Points
Problem Statement
You are given two groups of points where the first group has size1 points, the second group has size2 points, and size1 >= size2. The cost of the connection between any two points are given in an size1 x size2 matrix where cost[i][j] is the cost of connecting point i of the first group and point j of the second group. The groups are connected if each point in both groups is connected to one or more points in the opposite group. In other words, each point in the first group must be connected to at least one point in the second group, and each point in the second group must be connected to at least one point in the first group. Return the minimum cost it takes to connect the two groups.
Source: Minimum Cost to Connect Two Groups of Points on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
cost = [[15, 96], [36, 2]]
17
# Example 2
cost = [[1, 3, 5], [4, 1, 1], [1, 5, 3]]
4
# Example 3
cost = [[2, 5, 1], [3, 4, 7], [8, 1, 2], [6, 2, 4], [3, 8, 8]]
10
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Cost to Connect Two Groups of Points.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.