Problem on Dynamic Programming with KMP(Pattern Matching algorithm)

Revision en2, by Original_gangster, 2021-06-05 13:27:04

I am trying to solve a dp question from prepbytes and problem statment in simple words is as following:-

We are given 3 strings s1,s2,s3, we have to find longest common subsequence of s1 and s2 which does not contain s3 as its substring.

Problem link

In my approach , I tried to maintain current positions of s1 and s2, and the length of s3 that is matched in our common subsequence till now. The transitions are almost like the longest common subsequence problem. Then I tried to retrace to find the longest common subsequence. I am not able to figure out what is wrong with my code. Can anyone please help me in finding where I am going wrong.

Link to my code :- Link

Thanks in advance!!

Tags # dp, #kmp, #lcs, #string matching

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Original_gangster 2021-06-11 12:25:00 176
en2 English Original_gangster 2021-06-05 13:27:04 0 (published)
en1 English Original_gangster 2021-06-05 13:24:44 884 Initial revision (saved to drafts)