Original_gangster's blog

By Original_gangster, history, 4 years 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

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

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Original_gangster (previous revision, new revision, compare).