Sunday, 18 March 2018

Longest common sequence


Given sequences say “MNOP” and NPA

Longest common sequence of LCS is a sequence that appears in the same relative order in both the given sequence but not necessarily in a continuous manner.

See the example

M
N
O
P

N
P
A

So Longest common sequence (LCS) is

NP
And length of LCS would be 2