Skip to content

Commit 505a92d

Browse files
committed
Updating content for dynamic approach of change
1 parent 5db8204 commit 505a92d

File tree

1 file changed

+4
-2
lines changed
  • exercises/practice/change/.approaches/dynamic-programming

1 file changed

+4
-2
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ It minimizes the number of coins needed by breaking down the problem into smalle
6161
- After processing all values up to `grandTotal`, the combination at `coinsUsed[grandTotal]` will represent the most efficient solution.
6262
- If no valid combination exists for `grandTotal`, an exception is thrown.
6363

64-
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`.
64+
## Time and Space Complexity
65+
66+
- 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`.
6567

66-
The space complexity is **O(n)** due to the list `coinsUsed`, which stores the most efficient coin combination for each total up to `grandTotal`.
68+
- 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 commit comments

Comments
 (0)