Skip to content

Commit 39f6ba5

Browse files
committed
updated if only 1 value coin left, return 1
1 parent b4e3fa2 commit 39f6ba5

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Sprint-2/improve_with_caches/making_change/making_change.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ def ways_to_make_change_helper(total: int, coins: List[int], coin_index: int = 0
2323

2424
if total == 0:
2525
return 1
26+
27+
if coin_index == len(coins) - 1:
28+
return 1 if total % coins[coin_index] == 0 else 0
2629

2730
if total < 0 or coin_index >= len(coins):
2831
return 0

0 commit comments

Comments
 (0)