Skip to content

Commit c1d07e5

Browse files
committed
Fixing stle errors
1 parent 2fbec2a commit c1d07e5

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ This approach ensures that we find the most efficient way to make change and han
1414
2. **Iterative Dynamic Programming**:
1515

1616
- 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`.
17-
- 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).
17+
- 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).
1818
- 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.
1919

2020
3. **Result**:
2121

2222
- After processing all values up to `grandTotal`, the combination at `coinsUsed[grandTotal]` will represent the most efficient solution.
2323
- If no valid combination exists for `grandTotal`, an exception is thrown.
2424

25-
2625
```java
2726
import java.util.List;
2827
import java.util.ArrayList;
@@ -77,7 +76,7 @@ class ChangeCalculator {
7776

7877
- **Efficiency**: This approach is highly efficient in terms of minimizing the number of coins, but it might require significant memory for larger `grandTotal` values, as the space complexity grows linearly with `grandTotal`.
7978

80-
- **Alternative Approaches**:
79+
- **Alternative Approaches**:
8180

8281
- A **Greedy Approach** could be faster for some cases but does not always guarantee the minimum number of coins.
8382
- This dynamic programming approach is best when the goal is to guarantee the fewest coins possible, especially when no simple greedy solution exists.

exercises/practice/change/.approaches/intrduction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
In the "Change Calculator" exercise, the goal is to determine the minimum number of coins needed to reach a given total using a specific set of coin denominations. This is a classic problem in dynamic programming, where efficient change-making is essential, especially when there are constraints on coin types or large totals.
44

5-
### Problem Overview
5+
## Problem Overview
66

77
Given:
88

@@ -11,13 +11,13 @@ Given:
1111

1212
The solution should find the optimal combination of coins to match the total. If it's impossible to match the total exactly, the solution should indicate this by throwing an exception.
1313

14-
### Approach Overview
14+
## Approach Overview
1515

1616
Our solution uses a **dynamic programming approach**, where we systematically build up the optimal combinations for all totals from `0` up to the target amount (`grandTotal`). For each total, we track the fewest coins needed to make that total, reusing previous results to make the solution efficient.
1717

1818
This approach ensures that we find the minimum number of coins required in a structured, repeatable way, avoiding the need for complex recursive calls or excessive backtracking.
1919

20-
### Key Features of the Approach
20+
## Key Features of the Approach
2121

2222
- **Efficiency**: By building solutions for each increment up to `grandTotal`, this approach minimizes redundant calculations.
2323
- **Flexibility**: Handles cases where exact change is impossible by checking at each step.

0 commit comments

Comments
 (0)