Longest common substring

not getting correct output

Hey Tejasv, this is because your implementation is incorrect!
when the characters are unequal in both strings, don’t return 0 simply!
take this case:
abcd
bbcd
here answer is 3(not zero)
also make use of DP efficiently, instead of passing substrings, pass the pointer(denoting indexes for both strings) else you may run out of memory!

can you please correct my code


x="zxabcdezy”, y = “yzabcdezx”
output is 6
but my code output is 7


there you go!
also answer for given case is 7 only!

no sir its output is 6


check it
X = “zxabcdezy”, y = “yzabcdezx”
Output : 6
but code shows output is 7

I’m sorry, I misjudged this question as Longest increasing subsequence!, The code I provided is also for same!

can you provide code for longest common substring plzzz

Yeah sure, I’ll update the code

sir plzz provide link of code after updating

sir one more doubt after making dp table which is store in as per our code in t how to print longest common substring

and also explain the logic behind finding length of longest common substring


I 've commented the logic and made modification to store LCS!

ok sir how to print it???/

It is already stored in result variable!
you can simply do cout<<result;

sir this is the code which you sent me earlier where it is stored