diff --git a/dynamic_programming/coin_change.cpp b/dynamic_programming/coin_change.cpp index 8c8fc3dfb..bdde1e482 100644 --- a/dynamic_programming/coin_change.cpp +++ b/dynamic_programming/coin_change.cpp @@ -1,11 +1,13 @@ #include #include +#include using namespace std; // Function to find the Minimum number of coins required to get Sum S int findMinCoins(int arr[], int n, int N) { // dp[i] = no of coins required to get a total of i - int dp[N + 1]; + std::vector dp; + dp.reserve(N + 1); // 0 coins are needed for 0 sum