Run
#include <bits/stdc++.h>
using namespace std;
map< int, map< int,int>> m;
int LCS(string word1, string word2, int Index1, int Index2)
{
if(Index1 <0 || Index2 <0) return 0;
if(m[Index1][Index2]) return m[Index1][Index2];
if(word1[Index1]==word2[Index2]) return m[Index1][Index2] = 1+ LCS(word1,word2,Index1-1,Index2-1);
return m[Index1][Index2] = max(LCS(word1,word2,Index1,Index2-1),LCS(word1,word2,Index1-1,Index2));
}
int main()
{
string word1 = "PREPINSTA", word2 = "ENCODING";
cout<< (word1,word2,word1.length()-1,word2.length()-1);
}
Login/Signup to comment