Skip to content

Commit

Permalink
Update exercises/practice/change/.approaches/dynamic-programming/cont…
Browse files Browse the repository at this point in the history
…ent.md

Co-authored-by: Kah Goh <[email protected]>
  • Loading branch information
jagdish-15 and kahgoh authored Nov 19, 2024
1 parent c0a46c6 commit f76ad5d
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ It minimizes the number of coins needed by breaking down the problem into smalle
- 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.

- **Time Complexity**: The time complexity of this approach is **O(n * m)**, where `n` is the `grandTotal` and `m` is the number of available coin denominations. This is because we iterate over all coin denominations for each amount up to `grandTotal`.
The time complexity of this approach is **O(n * m)**, where `n` is the `grandTotal` and `m` is the number of available coin denominations. This is because we iterate over all coin denominations for each amount up to `grandTotal`.

- **Space Complexity**: The space complexity is **O(n)** due to the list `coinsUsed`, which stores the most efficient coin combination for each total up to `grandTotal`.

0 comments on commit f76ad5d

Please sign in to comment.