Skip to content

Commit 2fbec2a

Browse files
committed
Fixing style errors
1 parent 1aa6d9c commit 2fbec2a

File tree

1 file changed

+6
-3
lines changed
  • exercises/practice/change/.approaches/dynamic-programming

1 file changed

+6
-3
lines changed

exercises/practice/change/.approaches/dynamic-programming/content.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ This approach ensures that we find the most efficient way to make change and han
66

77
## Explanation
88

9-
1. **Initialize Coins Usage Tracker**:
9+
1. **Initialize Coins Usage Tracker**:
10+
1011
- We create a list `coinsUsed`, where each index `i` stores the most efficient combination of coins that sum up to the value `i`.
1112
- The list is initialized with an empty list at index `0`, as no coins are needed to achieve a total of zero.
1213

13-
2. **Iterative Dynamic Programming**:
14+
2. **Iterative Dynamic Programming**:
15+
1416
- For each value `i` from 1 to `grandTotal`, we explore all available coin denominations to find the best combination that can achieve the total `i`.
1517
- For each coin, we check if it can be part of the solution (i.e., if `coin <= i` and `coinsUsed[i - coin]` is a valid combination).
1618
- If so, we generate a new combination by adding the current coin to the solution for `i - coin`. We then compare the size of this new combination with the existing best combination and keep the one with fewer coins.
1719

18-
3. **Result**:
20+
3. **Result**:
21+
1922
- After processing all values up to `grandTotal`, the combination at `coinsUsed[grandTotal]` will represent the most efficient solution.
2023
- If no valid combination exists for `grandTotal`, an exception is thrown.
2124

0 commit comments

Comments
 (0)