Original_gangster's blog

By Original_gangster, history, 2 months ago, In English

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

Read more »

 
 
 
 
  • Vote: I like it
  • +15
  • Vote: I do not like it