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.