From a0abcbe4967d085298ea7311b013ed3d62ef37a2 Mon Sep 17 00:00:00 2001 From: realstealthninja <68815218+realstealthninja@users.noreply.github.com> Date: Fri, 4 Oct 2024 20:25:25 +0530 Subject: [PATCH] fix: vla in longest_common_subsequence --- dynamic_programming/longest_common_subsequence.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dynamic_programming/longest_common_subsequence.cpp b/dynamic_programming/longest_common_subsequence.cpp index 662c26ad2..89a57dc0e 100644 --- a/dynamic_programming/longest_common_subsequence.cpp +++ b/dynamic_programming/longest_common_subsequence.cpp @@ -1,5 +1,6 @@ // Longest common subsequence - Dynamic Programming #include +#include using namespace std; void Print(int trace[20][20], int m, int n, string a) { @@ -18,7 +19,7 @@ void Print(int trace[20][20], int m, int n, string a) { int lcs(string a, string b) { int m = a.length(), n = b.length(); - int res[m + 1][n + 1]; + std::vector > res(m + 1, std::vector(n + 1)); int trace[20][20]; // fills up the arrays with zeros.