Skip to content

Commit bf007a0

Browse files
committed
Longest Common Subsequence
1 parent e2799d8 commit bf007a0

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

lcs.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#include <iostream>
22
#include <string.h>
3-
43
using namespace std;
54

65
int lcs(char x[],char y[])
76
{
87
int i, j, m=strlen(x), n=strlen(y), r[m+1][n+1];
98
for(i=0; i<=m; i++)
10-
{
119
for(j=0; j<=n; j++)
1210
{
1311
if (i==0 || j==0)
@@ -17,7 +15,6 @@ int lcs(char x[],char y[])
1715
else
1816
r[i][j] = max(r[i-1][j], r[i][j-1]);
1917
}
20-
}
2118
return r[m][n];
2219
}
2320

@@ -26,6 +23,6 @@ int main()
2623
char x[50], y[50];
2724
cout<<"Enter the two strings: ";
2825
cin>>x>>y;
29-
cout<<"The length of the longest common subsequence is: "<<lcs(x, y);
26+
cout<<"The length of the longest common subsequence is: "<<lcs(x, y)<<endl;
3027
return 0;
3128
}

0 commit comments

Comments
 (0)