0 votes

For the general case of an arbitrary number of

input sequences, the problem is NP-hard. When the number of sequences is constant, the problem is solvable in polynomial time by dynamic programming (see *Solution* below). Assume you have Nsequences of lengths { n_{1},...,n_{N}}. A

naive search would test each of the { 2^{n_{1}}}subsequences of the first sequence to determine whether they are also subsequences of the remaining sequences; each subsequence may be tested in time linear in the lengths of the remaining sequences, so the time for this algorithm would be

{O(2^(n_(1))sum(n(i)):i>1}

For the case of two sequences of *n* and *m *elements, the running time of the dynamic programming approach is O(*n* × *m*)

source : https://en.m.wikipedia.org/wiki/Longest_common_subsequence_problem