From 7984cd41c83e1aeafe9bd8b835304d36aca08c05 Mon Sep 17 00:00:00 2001 From: realstealthninja <68815218+realstealthninja@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:11:46 +0530 Subject: [PATCH] fix: dynamic array in coin_change --- dynamic_programming/coin_change.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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