We can reduce the Longest Common Subsequence problem to Longest Increasing Subsequence problem if at most one sequence has repetitions. The process of reducing the problem is explained here:
Suppose you have the sequences:
S1 = {D, B, A, C, E} S2 = {E, Z, X, D, A, Y, C}Then, create a sequence of integers S3, where you have to put the position of each element of S2 in S1 (if the element doesn't exists in S1, then ignore that element). In the example:
S3 = {4, 0, 2, 3} // Z, X and Y in S2 where ignoredThen, just find the LIS in S3. To find the original elements, just use the integers in the LIS as indices of S1. For example, in this case the LIS of S3 is
{0, 2, 3}, where that represents the sequence{D, A, C}.
How does this approach work? Why does this reduction solve the problem of finding the longest common subsequence?