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


in reply to Longest Common Subsequence Question

Your method would fail for

S1 = aabbb S2 = aabbb S3 = aa

The answer is "aa", but your method will try to find the LCS("bbb", "aa") and will fail to find a result.

Update: Oops, I meant

S1 = aa1bbb S2 = aa2bbb S3 = aa

Replies are listed 'Best First'.
Re^2: Longest Common Subsequence Question
by Anonymous Monk on Nov 19, 2007 at 04:11 UTC
    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?

      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.
        Thank you all. This one got me thinking for awhile there.