Skip to content

Commit

Permalink
Fixing style errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jagdish-15 committed Nov 9, 2024
1 parent e8d2787 commit 6152c10
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ This approach ensures that we find the most efficient way to make change and han

## Explanation

1. **Initialize Coins Usage Tracker**:
1. **Initialize Coins Usage Tracker**:

- We create a list `coinsUsed`, where each index `i` stores the most efficient combination of coins that sum up to the value `i`.
- The list is initialized with an empty list at index `0`, as no coins are needed to achieve a total of zero.

2. **Iterative Dynamic Programming**:
2. **Iterative Dynamic Programming**:

- 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`.
- 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).

Check failure on line 17 in exercises/practice/change/.approaches/dynamic-programming/content.md

View workflow job for this annotation

GitHub Actions / Lint Markdown files

Trailing spaces

exercises/practice/change/.approaches/dynamic-programming/content.md:17:136 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md009.md
- 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.

3. **Result**:
3. **Result**:

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

Expand Down

0 comments on commit 6152c10

Please sign in to comment.