http://www.perlmonks.org?node_id=651580


in reply to Re: Longest Common Subsequence Question
in thread Longest Common Subsequence Question

I thought the longest common subsequence between S1 and S2 in this case is aabbb.
And then the longest common subsequence between this result aabbb and S3 (aa) is aa. Am I missing something?
  • Comment on Re^2: Longest Common Subsequence Question

Replies are listed 'Best First'.
Re^3: Longest Common Subsequence Question
by ikegami (Patriarch) on Nov 19, 2007 at 04:20 UTC

    Oops, I meant

    S1 = aa1bbb S2 = aa2bbb S3 = aa
      with S1=aa1bbb and S2=aa2bbb the longest common subsequence between them still would be aabbb and the longest common subsequence between aabbb and aa would still be aa. This is the longest common subsequence, not the longest common substring.
        oh, it doesn't have to be contiguous? Then yeah, your method would work.

        Update: Pardon the disaster that was my participation in this thread.

      Thank you all. This one got me thinking for awhile there.