Skip to content

Commit a0abcbe

Browse files
fix: vla in longest_common_subsequence
1 parent 2b278e9 commit a0abcbe

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

dynamic_programming/longest_common_subsequence.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Longest common subsequence - Dynamic Programming
22
#include <iostream>
3+
#include <vector>
34
using namespace std;
45

56
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) {
1819

1920
int lcs(string a, string b) {
2021
int m = a.length(), n = b.length();
21-
int res[m + 1][n + 1];
22+
std::vector<std::vector<int> > res(m + 1, std::vector<int>(n + 1));
2223
int trace[20][20];
2324

2425
// fills up the arrays with zeros.

0 commit comments

Comments
 (0)