Longest common subsequence: Difference between revisions

m
Removed duplicate Examples section.
(Updated Introduction.)
m (Removed duplicate Examples section.)
Line 16:
If i1 &le; i2 and j2 &le; j1 (or i2 &le; i1 and j1 &le; j2) then neither m1 < m2 nor m1 > m2 are possible; and m1, m2 are ''incomparable''.
 
Defining (#) to denote this case, we write m1 # m2. Because the underlying product -order is strict, m1 == m2 (''i.e.'', i1 == i2 and j1 == j2) implies m1 # m2. Thus, the (<>) operator is the inverse of (#).
 
Because the product -order is strict, m1 <> m2 implies m1 &ne; m2, ''i.e.'', that the two tuples differ in some component.
 
Given a product-order over the set of matches '''M''', a chain '''C''' is any subset of '''M''' where m1 <> m2 for every pair of distinct elements m1 and m2 of '''C'''. Similarly, an antichain '''D''' is any subset of '''M''' where m1 # m2 for every pair of distinct elements m1 and m2 of '''D'''.
Line 78:
Elsevier Science [Volume 75, ''pp.'' 275–281]
<br />
'''Examples'''
 
The sequences "1234" and "1224533324" have an LCS of "1234":
'''<u>1234</u>'''
'''<u>12</u>'''245'''<u>3</u>'''332'''<u>4</u>'''
 
For a string example, consider the sequences "thisisatest" and "testing123testing". An LCS would be "tsitest":
'''<u>t</u>'''hi'''<u>si</u>'''sa'''<u>test</u>'''
'''<u>t</u>'''e'''<u>s</u>'''t'''<u>i</u>'''ng123'''<u>test</u>'''ing
 
In this puzzle, your code only needs to deal with strings. Write a function which returns an LCS of two strings (case-sensitive). You don't need to show multiple LCS's.
 
For more information on this problem please see [[wp:Longest_common_subsequence_problem|Wikipedia]].
<br />
'''Examples'''
 
159

edits