Skip to content

Commit 04bc612

Browse files
Update 1595 - Minimum Cost to Connect Two Groups of Points.md
1 parent 3c35f71 commit 04bc612

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

dsa-solutions/lc-solutions/1500-1599/1595 - Minimum Cost to Connect Two Groups of Points.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ description: "This document provides a solution where we return the minimum cost
1313
---
1414
## Problem
1515

16-
You are given two groups of points where the first group has size1 points, the second group has size2 points, and size1 >= size2.
16+
You are given two groups of points where the first group has $size1$ points, the second group has $size2$ points, and $size1 >= size2$.
1717

18-
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.
18+
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.
1919

2020
### Examples
2121

@@ -94,7 +94,7 @@ There are four approaches discussed that helps to obtain the solution:
9494
- Use memoization to store and reuse results of subproblems to improve efficiency.
9595

9696
4. **Base and Transition**:
97-
- **Base Case:** If all points in the first group are processed (i == size1), calculate the cost to connect any remaining points in the second group that have not been connected.
97+
- **Base Case:** If all points in the first group are processed (i == $size1$), calculate the cost to connect any remaining points in the second group that have not been connected.
9898

9999
- **Transition:** For each point in the second group, update the bitmask and recursively calculate the minimum cost.
100100

@@ -158,13 +158,13 @@ This problem can be solved using dynamic programming. The problem requires conne
158158

159159
### Complexity Analysis
160160

161-
#### Time Complexity: O(size1 × 2^size2 x size2)
161+
#### Time Complexity: O($size1$ × $2^size2$ x $size2$)
162162

163-
> **Reason**: There are 'size 1' points in the first group, and each point can potentially connect to any subset of the 'size2' points in the second group, leading to 2^size2 possible states for the bitmask. For each state, we iterate over all points in the second group, hence the additional factor of 'size2'.
163+
> **Reason**: There are $'size 1'$ points in the first group, and each point can potentially connect to any subset of the $'size2'$ points in the second group, leading to $'2^size2'$ possible states for the bitmask. For each state, we iterate over all points in the second group, hence the additional factor of $'size2'$
164164
165-
#### Space Complexity: O(size1 × 2^size2)
165+
#### Space Complexity: O($size1$ × $2^size2$)
166166

167-
> **Reason**: Additional space is used for the recursion stack, which is O(size1).
167+
> **Reason**: Additional space is used for the recursion stack, which is O($size1$).
168168
169169
# References
170170

0 commit comments

Comments
 (0)