mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-05-11 19:17:21 +08:00
fix: vla in longest_common_subsequence
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
// Longest common subsequence - Dynamic Programming
|
// Longest common subsequence - Dynamic Programming
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void Print(int trace[20][20], int m, int n, string a) {
|
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 lcs(string a, string b) {
|
||||||
int m = a.length(), n = b.length();
|
int m = a.length(), n = b.length();
|
||||||
int res[m + 1][n + 1];
|
std::vector<std::vector<int> > res(m + 1, std::vector<int>(n + 1));
|
||||||
int trace[20][20];
|
int trace[20][20];
|
||||||
|
|
||||||
// fills up the arrays with zeros.
|
// fills up the arrays with zeros.
|
||||||
|
|||||||
Reference in New Issue
Block a user