Skip to content

Commit b75a34f

Browse files
committed
feat(Codewars): Solve onlinePlatform/codewars/4kyu/counting_change_combinations.cc
1 parent 0e821ae commit b75a34f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/onlinePlatform/codewars/4kyu/counting_change_combinations.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ unsigned long long countChange(const unsigned int money, const std::vector<unsig
1515
std::vector<long long> counts(money + 1);
1616
counts[0] = 1;
1717
for (auto coin: uniqueCoins) {
18-
std::vector<long long> prev(begin(counts), end(counts));
19-
counts = std::vector<long long>(money + 1);
20-
21-
for (auto i = money; i >= coin; --i) {
22-
counts[i] += prev[i - coin];
18+
for (auto i = coin; i <= money; ++i) {
19+
counts[i] += counts[i - coin];
2320
}
2421
}
2522

0 commit comments

Comments
 (0)