Skip to content

Commit

Permalink
Fixing styling issues for approache for Change
Browse files Browse the repository at this point in the history
  • Loading branch information
jagdish-15 committed Nov 18, 2024
1 parent 2758bc3 commit c0a46c6
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ It minimizes the number of coins needed by breaking down the problem into smalle

1. **Initialize Coins Usage Tracker**:

- If the `grandTotal` is negative, an exception is thrown immediately.
- If the `grandTotal` is negative, an exception is thrown immediately.
- 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.

Expand All @@ -61,7 +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`.

- **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 c0a46c6

Please sign in to comment.