Skip to content

Commit 7984cd4

Browse files
fix: dynamic array in coin_change
1 parent c7064a6 commit 7984cd4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

dynamic_programming/coin_change.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#include <climits>
22
#include <iostream>
3+
#include <vector>
34
using namespace std;
45

56
// Function to find the Minimum number of coins required to get Sum S
67
int findMinCoins(int arr[], int n, int N) {
78
// dp[i] = no of coins required to get a total of i
8-
int dp[N + 1];
9+
std::vector<int> dp;
10+
dp.reserve(N + 1);
911

1012
// 0 coins are needed for 0 sum
1113

0 commit comments

Comments
 (0)