Problem on Dynamic Programming with KMP(Pattern Matching algorithm)

Правка en3, от Original_gangster, 2021-06-11 12:25:00

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!!

UPD:- Found same problem on codeforces and submitted the same code mentioned above and it got accepted!!

Problem link

Теги # dp, #kmp, #lcs, #string matching


  Rev. Язык Кто Когда Δ Комментарий
en3 Английский Original_gangster 2021-06-11 12:25:00 176
en2 Английский Original_gangster 2021-06-05 13:27:04 0 (published)
en1 Английский Original_gangster 2021-06-05 13:24:44 884 Initial revision (saved to drafts)