improved the code

This commit is contained in:
Christian Bender 2018-03-27 23:14:19 +02:00
parent cc9e8d0d17
commit d3185357bd

View File

@ -25,10 +25,22 @@ 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 res[m+1][n+1];
int trace[20][20];
// fills up the arrays with zeros.
for (int i = 0; i < m+1; i++)
{
for (int j = 0; j < n+1; j++)
{
res[i][j] = 0;
trace[i][j] = 0;
}
}
for (int i = 0; i < m+1; ++i)
{
for (int j = 0; j < n+1; ++j)