gives correct output then also gives MLE on each test case therefore not accepted…
what to do ?
gives correct output then also gives MLE on each test case therefore not accepted…
what to do ?
Modified Code
change the size of dp
int dp[1001][1001];
send the question link as well
from hacker blocks
A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence {A,B,D} is a subsequence of {A,B,C,D,E,F}, obtained after removal of elements C, E and F.
Given two strings A and B of size n and m respectively, you have to print the Longest Common Subsequence(LCS) of strings A and B, where LCS is the longest sequence present in both A and B.
Note: It is gauranteed that there is only one unique longest common subsequence
Input Format
Two strings A and B.
Constraints
1 <= n,m <= 10^3
Output Format
Output the LCS of A and B.
Sample Input
abc acd
Sample Output
ac
actually you have not print the answer comming from function
at line no 37 put a cout
cout<<f(s1, s2, s3, 0, 0, 0)<<endl;
sorry this is the lcs of 3 strings–>
Given 3 strings ,the task is to find the longest common sub-sequence in all three given sequences.
Input Format
First line contains first string . Second line contains second string. Third line contains the third string.
Constraints
The length of all strings is |s|< 200
Output Format
Output an integer denoting the length of longest common subsequence of above three strings.
Sample Input
GHQWNV SJNSDGH CPGMAH
Sample Output
2
Explanation
“GH” is the longest common subsequence